VioletaBabel
개구리 뛰기 본문
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
setbuf(stdout, NULL);
int T;
int test_case;
scanf("%d", &T);
for (test_case = 1; test_case <= T; ++test_case) {
int *a = new int[1000001];
int n, k, count = 1;
scanf("%d", &n);
for (int i = 1; i < n + 1; i++)
scanf("%d", &a[i]);
scanf("%d", &k);
int frog = k;
for (int i = 1; i < n + 1; i++)
{
if (a[i] <= frog)
continue;
else if ((a[i] - a[i - 1]) > k)
{
count = -1;
break;
}
++count;
frog = a[i - 1] + k;
}
printf("Case #%d\n%d\n", test_case, count);
delete[] a;
}
return 0;
}
'알고리즘문제들 > codeground' 카테고리의 다른 글
스타벅스 (0) | 2017.06.28 |
---|---|
태준이의 걱정 (0) | 2017.06.28 |
체스판 위의 길 (실패) (0) | 2017.06.17 |
화학자의 문장 (99점) (0) | 2017.06.16 |
블럭 없애기 (실패) (0) | 2017.06.16 |
Comments