Submission #848902

#TimeUsernameProblemLanguageResultExecution timeMemory
848902sandry24Sure Bet (CEOI17_sure)C++17
20 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second void solve(){ int n; cin >> n; vector<float> a(n), b(n); for(int i = 0; i < n; i++) cin >> a[i] >> b[i]; sort(a.begin(), a.end(), greater<float>()); sort(b.begin(), b.end(), greater<float>()); double total_a = 0, total_b = 0, total_max = 0; for(int i = 0; i < n; i++){ total_b += b[i]; total_max = max(total_max, min(total_a - (i+1), total_b - (i+1))); } total_b = 0; for(int i = 0; i < n; i++){ total_a += a[i]; total_b = 0; total_max = max(total_max, min(total_a, total_b - (i+1))); //cout << total_a << ' ' << -(i+1) << '\n'; for(int j = 0; j < n; j++){ total_b += b[j]; total_max = max(total_max, min(total_a - (j+i+2), total_b - (j+i+2))); //cout << total_a - (j+i+2) << ' ' << total_b - (j+i+2) << ' ' << total_b << '\n'; } } printf("%.4lf", total_max); } int main(){ //freopen("flota.in", "r", stdin); //freopen("flota.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...