Submission #877991

#TimeUsernameProblemLanguageResultExecution timeMemory
877991fanwenSure Bet (CEOI17_sure)C++17
100 / 100
84 ms3828 KiB
#pragma GCC optimize("O2") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define fi first #define se second #define ll long long #define mp make_pair #define ii pair<int,int> #define MASK(i) (1LL<<(i)) #define BIT(x,i) (((x)>>(i))&1) #define all(x) (x).begin(),(x).end() using namespace std; const int maxn = 1e5 + 5; const int N = 1e3 + 1; const int mod = 1e9 + 7; template <class X,class Y>bool maximize(X &a,Y b) { if(a<b)return a=b,true; return false;} template <class X,class Y>bool minimize(X &a,Y b) { if(a>b)return a=b,true; return false;} #define TASK "" void file() { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout);} #define fasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ld long double int n,i,j; ld a[maxn],b[maxn]; int na,nb; ld A,B; ld Max = 0.000; int main() { // file(); fasterIO; cin >>n; for(i=1;i<=n;i++) cin>>a[i]>>b[i],a[i]--,b[i]--; sort(a+1,a+n+1,greater<ld>()); sort(b+1,b+n+1,greater<ld>()); for(i=1;i<=n;i++){ A += a[i] , ++na; while(nb < n && min(A-nb,B-na) < min(A - nb -1, B + b[nb+1] - na)){ B += b[nb+1]; nb++; } maximize(Max,min(A-nb,B-na)); } cout << fixed << setprecision(4) << Max << '\n'; return 0; }

Compilation message (stderr)

sure.cpp: In function 'void file()':
sure.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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(TASK ".out", "w", stdout);}
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...