|
|
back to boardWA Test #3 Posted by TwoFace 14 Jul 2015 10:25 import java.util.*; import java.io.*; public class MEGA { public static void main(String arg[]) { int k,n,i,sum=0; Scanner scan=new Scanner(System.in); k=scan.nextInt(); n=scan.nextInt(); int[] a=new int[n]; for(i=0;i<n;) { if(scan.hasNextInt()) { a[i]=scan.nextInt(); i++; } } for(i=0;i<n;i++) { sum+=a[i]-k; } if(sum<0) { System.out.println("1"); } else { System.out.println(""+sum); } } } This very simple program is turning out to be a headache. What is Test #3? Re: WA Test #3 inside cycle you need to check that (sum + a[i] - k) >=0 Edited by author 04.12.2016 16:18 Edited by author 04.12.2016 16:18 |
|
|