B. Painting Eggs
J draws n eggs, which can be bought to A and G respectively. The bid for each egg A and G is different, but the requirement is, the price difference between the eggs sold to A and G cannot exceed 500;
/*
I did not understand the problem at the time, so I did not get it, and I got another 57 points.
If every question is a Chinese question, it should be the expectation of many Chinese students working on codeforces;
What should I do with the weakness of English...
*/
Greedy:
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # include <string> # include <iomanip> # define maxn 1000010 char str [maxn]; using namespace std; int main (int argc, char * argv []) {int n, sa, sb, a, B, I = 0; sa = sb = 0; cin> n; while (n --) {cin> a> B; if (sa + a-sb <= 500) {sa + =; str [I ++] = 'a';} else {if (sb + B-sa <= 500) {sb + = B; str [I ++] = 'G';} else {puts ("-1") ;}} puts (str); return 0 ;}