###### CodeForces - 557A Ilya and Diplomas

Ilya and Diplomas
Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u

Submit Status

Description

Input

Output

Sample Input

6
1 5
2 6
3 7

10
1 2
1 3
1 5

6
1 3
2 2
2 2

Sample Output

1 2 3

2 3 5

2 2 2


import java.util.Scanner;

public class Main{
private static  int num =0,sum;
private static Node[] node = new Node[3];
private static int[] array = new int [3];
private static int[] resarray =  new int[3];

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
num = scanner.nextInt();
for (int i = 0; i < 3; i++) {
Node Tnode = new Node();
Tnode.min = scanner.nextInt();
Tnode.max = scanner.nextInt();
array[i] = Tnode.max - Tnode.min;
node[i]=Tnode;
sum += Tnode.min;
}
if (sum == num) {
System.out.printf("%d %d %d\n",node[0].min,node[1].min,node[2].min);
}else {
int m = num - sum;
if (m<=array[0]) {
resarray[0] = node[0].min+m;
m=0;
}else {
resarray[0] = node[0].max;
m-=array[0];
}
if (m<=array[1]) {
resarray[1] = node[1].min+m;
m=0;
}else {
resarray[1] = node[1].max;
m -= array[1];
}
if (m<=array[2]) {
resarray[2] = node[2].min+m;
m = 0;
}else {
m-= array[2];
}
System.out.printf("%d %d %d\n",resarray[0],resarray[1],resarray[2]);
}
}
scanner.close();
}
static class Node{
int min;
int max;
}

}


#### CodeForces 557A Ilya and Diplomas

2016-09-14 18:19:47

#### CodeForces 557A Ilya and Diplomas

2016-06-30 18:36:28

#### Codeforces 557A Ilya and Diplomas 【水题】

2016-04-21 18:04:36

#### 【CodeForces】557A - Ilya and Diplomas（水）

2016-04-22 09:01:10

#### cf#311 A. Ilya and Diplomas

2015-07-01 12:39:52

#### Codeforces 557A Ilya and Diplomas 区间选数

2015-07-01 04:22:31

#### CodeForces - 557A Ilya and Diplomas （模拟）水

2016-04-21 21:38:47

#### CF 557A(Ilya and Diplomas-贪心)

2015-07-01 21:08:09

#### Codeforces 842C Ilya And The Tree（树上DP+因子个数估计）

2017-08-30 11:05:57

## 不良信息举报

CodeForces - 557A Ilya and Diplomas