|  | 
|  | 
| вернуться в форум | WA #14 please help I've passed all of the user tests on here, and any test I can think of.Still getting WA on #14.
 Here's my non-working code.
 
 import java.io.*;
 
 public class P1998 {
 static StreamTokenizer in;
 static PrintWriter out;
 
 static int nextInt() throws IOException{
 do{
 in.nextToken();
 }while(in.ttype != StreamTokenizer.TT_NUMBER);
 return (int)in.nval;
 }
 
 public static void main(String[] args) throws IOException{
 in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
 out = new PrintWriter(System.out);
 
 int n = nextInt();
 int m = nextInt();
 int k = nextInt();
 
 int[] stones = new int[n];
 int[] dropsTo = new int[n];
 
 int tmp = 0, j = 0;
 for(int i = 0; i < n; i++){
 stones[i] = nextInt();
 
 while(j < i - 1 && tmp - stones[j] > k){
 tmp -= stones[j];
 j++;
 }
 tmp += stones[i];
 dropsTo[i] = j;
 }
 
 j = 0;
 int moment, time = 0;
 for(int i = 0; i < m; i++){
 moment = nextInt() - time;
 
 time += moment;
 j += moment - 1;
 if(j >= n){
 time -= moment - n;
 j = n;
 break;
 }
 j = dropsTo[j];
 }
 
 out.println(time + n - j);
 out.flush();
 }
 }
 | 
 | 
|