Ural1876 (greedy)

Source: Internet
Author: User

Topic Link: Click to open the link


Problem Solving Ideas:

In accordance with two aspects to greed: first 1th, we can think of all the right foot of the shoes to wear, and then put all the remaining right foot shoes discarded, finally wear enough left foot. i.e. B * 2 + 40;

2nd, we first wear 39 right foot shoes, and then wear 40 left foot shoes, then we put all the left foot shoes discarded, and finally spend 1s time to wear 1 right foot shoes. That is, 2 + 2 * (a-40) + 1;

The maximum value can be taken in both.


Full code:

#include <algorithm> #include <iostream> #include <cstring> #include <climits> #include < cstdio> #include <string> #include <cmath> #include <map> #include <queue>using namespace std ; typedef long long ll;const int MOD = int (1e9) +7;const int INF = 0x3f3f3f3f;const double EPS = 1e-9;const double PI = ACOs (-1.0); M_pi;int Main () {    #ifdef doubleq    freopen ("In.txt", "R", stdin);    #endif    int A, b;    while (Cin >> a >> b)    {        int res = MAX (b * 2 + 119, + 2 * (a-40));        cout << res << endl;    }}

More highlights please visit: Click to open the link

Ural1876 (greedy)

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.