include iostream include vector include string using namespace std int

 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
45
46
47
48
49
50
51
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
while (n != 0)
{
string temp;
long long s1 = 0, s2 = 0;
int a1 = 0, a2 = 0, a = -1, b = 0;
getline(cin, temp);
for (int i = 0; i < n; i++)
{
getline(cin, temp);
reverse(temp.begin(), temp.end());
int r = 0, t = 1;;
while (temp[r] != ' ')
{
a2 += t * (temp[r] - '0');
t *= 10;
r++;
}
t = 1; r++;
while (temp[r] != ' ')
{
a += t * (temp[r] - '0');
t *= 10;
r++;
}
s1 += a1;
s2 += a2;
if (a < a1)
{
a = a1;
b = a2;
}
}
s2 += m - b;
if (s2 > s1)
cout << "Success" << endl;
else
cout << "Fail" << endl;
cin >> n >> m;
}
return 0;
}