Submission #879279

#TimeUsernameProblemLanguageResultExecution timeMemory
879279vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
72 ms26964 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma optimization_level 3 // Defines #define pb push_back // kak push_back 5 #define endl '\n' #define FOR(i,start,end) for(int i = start;i < end;i ++) #define REV(i,start,end) for(int i = start;i >= end;i --) #define precal(x) fixed << setprecision(x) #define F first #define S second #define sz(x) (ll)x.size() #define all(x) (x).begin(),(x).end() #define m_p make_pair #define mt make_tuple #define str to_string // #ifndef ONLINE_JUDGE // #define cerr if(false) cerr // #endif const ll mxn = 1e6 + 1; // const ll k = 400; // const ll org = 10000; const ll inf = 1e9 + 7; // const ll mod = 998244353; ll n,m,t[4 * mxn],a[mxn]; bool au,us[mxn]; ll used[mxn]; vector <ll> v[mxn]; ll deg(ll x,ll p){ ll ans = 1; while(p --) ans *= x; return ans; } int main(){ // freopen("sparse.in","r",stdin); // freopen("sparse.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ll tt = 1; // cin >> tt; while(tt --){ ll n; cin >> n; vector <double> a(n),b(n); FOR(i,0,n){ cin >> a[i] >> b[i]; } sort(a.rbegin(),a.rend()),sort(b.rbegin(),b.rend()); double mx = 0.0,sum = 0.0,summ = 0.0,x = 0,y = 0; while(x < n || y < n){ if(x == 0 && y == 0){ sum = a[x],summ = b[y]; mx = max(mx,min(sum,summ) - (x + y + 2)); } if(sum > summ){ if(y + 1 < n){ y ++; summ += b[y]; mx = max(mx,min(sum,summ) - (x + y + 2)); } else break; } else if(sum < summ){ if(x + 1 < n){ x ++; sum += a[x]; mx = max(mx,min(sum,summ) - (x + y + 2)); } else break; } else{ if(x + 1 < n){ x ++; sum += a[x]; } else{ y ++; summ += b[y]; } mx = max(mx,min(sum,summ) - (x + y + 2)); } } cout << precal(4) << mx; } }

Compilation message (stderr)

sure.cpp:9: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    9 | #pragma GCC optimization ("O3")
      | 
sure.cpp:10: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   10 | #pragma GCC optimization ("unroll-loops")
      | 
sure.cpp:11: warning: ignoring '#pragma optimization_level ' [-Wunknown-pragmas]
   11 | #pragma optimization_level 3
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...