Submission #161701

#TimeUsernameProblemLanguageResultExecution timeMemory
161701MinnakhmetovSure Bet (CEOI17_sure)C++14
100 / 100
175 ms11656 KiB
#include <bits/stdc++.h> #define ll long long #define all(aaa) aaa.begin(), aaa.end() using namespace std; #define int long long int getInt(string s) { int x = 0; for (char c : s) { if (c != '.') x = x * 10 + c - '0'; } int y = 0; while (*(s.end() - y - 1) != '.') y++; while (y++ < 4) x *= 10; return x; } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n; cin >> n; multiset<int> sta, stb; for (int i = 0; i < n; i++) { string a, b; cin >> a >> b; // cout << getInt(a) << " " << getInt(b) << "\n"; sta.insert(getInt(a)); stb.insert(getInt(b)); } int sa = 0, sb = 0, ans = 0; for (int i = 1; i <= 2 * n; i++) { if (sa > sb) { if (stb.empty()) break; sb += *stb.rbegin(); stb.erase(prev(stb.end())); } else { if (sta.empty()) break; sa += *sta.rbegin(); sta.erase(prev(sta.end())); } ans = max(ans, min(sa, sb) - i * 10000); } string s; while (ans > 0) { s.push_back(ans % 10 + '0'); ans /= 10; } while (s.size() < 5) s.push_back('0'); reverse(all(s)); s.insert(s.end() - 4, '.'); cout << s; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...