ㅎㅇㅎㅇㅎㅇㅎㅇㅎㅇㅎㅇㅎㅇ
import java.util.ArrayList;
import java.util.Scanner;
public class Solution {
public static void main(String args[]) throws Exception {
//Scanner sc = new Scanner(new FileInputStream("input.txt"));
Scanner sc = new Scanner(System.in);
boolean found=false;
int T;
int test_case;
T = sc.nextInt();
for(test_case = 1; test_case <= T; test_case++) {
int now = 0;
int tmp = 0;
int next_now=0;
// 이 부분에서 알고리즘 프로그램을 작성하십시오. 기본 제공된 코드를 수정 또는 삭제하고 본인이 코드를 사용하셔도 됩니다.
int size = sc.nextInt();
ArrayList<Integer> list = new ArrayList();
int i;
for(i=0;i<size;i++)
list.add(sc.nextInt());
int move = sc.nextInt();
i=0;
int count=0;
while(i!=size)
{
tmp=now+move;
while(i!=size)
{
if(tmp-list.get(i)>=0)
{
next_now=i;
i++;
}
else
{
next_now=(i-1);
break;
}
}
if(now==list.get(next_now))
{
count= -1;
break;
}
count++;
now=list.get(next_now);
}
// 이 부분에서 정답을 출력하십시오.
System.out.println("Case #" + test_case);
System.out.println(count);
}
}
}
'왜안 고딩요 > jjjjava' 카테고리의 다른 글
경진대회 3 자연수 n의 최소진법 구하기 (0) | 2015.10.26 |
---|---|
경진대회 2 방속의 거울 (0) | 2015.10.26 |