-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.java
44 lines (41 loc) · 897 Bytes
/
test1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class test1
{
public static void main (String[] args) throws IOException
{
Scanner rdr=new Scanner(System.in);
int mush[]=new int[10];
int curr,sum=0,min=0,max=0;
for(int i=0;i<10;++i)
mush[i]=rdr.nextInt();
for(int j=0;j<10;++j)
{
sum+=mush[j];
if(sum>100)
{
max=sum;
min=sum-mush[j];
max = max - 100;
min = 100 - min;
if((min)<(max))
System.out.println(100-min);
else
System.out.println(100+max);
break;
}
else if((sum<100) && (j==mush.length-1))
{
System.out.println(sum);
}
else if(sum==100)
{
System.out.println(sum);
break;
}
}
}
}