Codeforces Round #173 (Div. 2) Problem B

Source: Internet
Author: User

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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.