Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ednakvidvoiki {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.next());
- int sum = 0 ;
- int diff=0;
- int sum2 = 0;
- for(int i=1 ; i<= n ; i++) {
- int cn = scan.nextInt();
- int cn2 = scan.nextInt();
- sum = cn + cn2;
- if(sum > sum2) {
- diff = sum - sum2;
- }else {
- diff= sum2 - sum;
- }
- sum2 = sum;
- }
- if( diff == 0) {
- System.out.println("Yes,value =" + sum);
- }else {
- System.out.println("No,maxdiff=" + diff);
- }
- }
- }
Add Comment
Please, Sign In to add comment