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)