Run time error on test 1

Revision en1, by _dattebayo, 2021-03-26 12:56:25

Hello guys, I was uploading my solution on this problem: https://codeforces.me/problemset/problem/120/C but it gave me run time error on test 1 , I don't know why? and here is my code in java

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int n,k,a,time,sum=0; boolean bool; n =read.nextInt(); k = read.nextInt(); for(int i=1;i<=n;i++){ a = read.nextInt(); time=0; bool = true; while(bool){ if(a<k||time==3){ sum = sum+a; bool = false; continue; } time++; a=a-k; } } System.out.println(sum); } }

Tags #implementation, math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English _dattebayo 2021-03-26 13:00:00 0 (published)
en3 English _dattebayo 2021-03-26 12:58:55 21
en2 English _dattebayo 2021-03-26 12:57:31 664
en1 English _dattebayo 2021-03-26 12:56:25 887 Initial revision (saved to drafts)