Submission #1027367

#TimeUsernameProblemLanguageResultExecution timeMemory
1027367vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
50 ms8284 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long // #define double long double #define endl '\n' #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define setmin(x, y) x = min((x), (y)) #define setmax(x, y) x = max((x), (y)) #define sqr(x) ((x) * (x)) #define fi first #define se second // mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count()); // int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);} const int NM = 1e6 + 5; const int mod = 1e6 + 3; const int inf = 1e9 + 1; int n; double a[NM], b[NM], ans, cur, A, B; signed main() { if (fopen("in.txt", "r")) { freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); } fastIO cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + 1 + n, greater<double>()); sort(b + 1, b + 1 + n, greater<double>()); int pa = 0, pb = 0; while (pa < n || pb < n) { if (pa == n) { ++pb; B += b[pb]; } else if (pb == n) { ++pa; A += a[pa]; } else if (A <= B) { ++pa; A += a[pa]; } else { ++pb; B += b[pb]; } setmax(ans, min(A, B) - pa - pb); } cout << fixed << setprecision(4) << ans; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen("in.txt","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
sure.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen("out.txt","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...