[SWEA] 4789 성공적인 공연 기획

Time Lapse :9min 54sec

4789.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <string.h>
char buf[1002];
int main(void) {
int T, tc = 0, ans, cur, len;
scanf("%d", &T);
while (T--) {
ans = 0;
scanf("%s",buf);
cur = buf[0]&0b1111;
len = strlen(buf);
for(int i = 1; i < len; ++i){
if(!(buf[i]&0b1111)) continue;
if(cur<i) ans += i-cur, cur = i + (buf[i]&0b1111);
else cur += (buf[i]&0b1111);
}
printf("#%d %d\n",++tc,ans);
}
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/4789/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.