제출 #468529

#제출 시각아이디문제언어결과실행 시간메모리
468529Vladth11Sure Bet (CEOI17_sure)C++14
100 / 100
165 ms3580 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast,unroll-loops") using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair <int, int> pii; typedef pair <long double, pii> muchie; typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> OST; const ll NMAX = 100001; const ll INF = (1LL << 60); const ll HALF = (1LL << 59); const ll MOD = 30013; const ll BLOCK = 318; const ll base = 31; const ll nr_of_bits = 21; double a[NMAX]; double b[NMAX]; int n; int main() { int i, j; cin >> n; for(i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1); sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1); double maxim = 0; int sum = 0; i = 1, j = 1; double sa = 0, sb = 0; for(int bets = 1; bets <= 2 * n; bets++){ if(sa == sb) { ///poate mai facem ceva modificari if(j > n) { sa += a[i]; i++; continue; } if(i > n) { sb += b[j]; j++; continue; } if(a[i] < b[j]) { sb += b[j]; j++; continue; } sa += a[i]; i++; } else if(sa < sb) { if(i > n) { sb += b[j]; j++; continue; } sa += a[i]; i++; } else if(sa > sb) { if(j > n) { sa += a[i]; i++; continue; } sb += b[j]; j++; } maxim = max(maxim, min(sa, sb) - bets); } cout << fixed << setprecision(4) << maxim; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sure.cpp: In function 'int main()':
sure.cpp:38:9: warning: unused variable 'sum' [-Wunused-variable]
   38 |     int sum = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...