제출 #1276739

#제출 시각아이디문제언어결과실행 시간메모리
1276739herominhsteveSure Bet (CEOI17_sure)C++20
100 / 100
49 ms2008 KiB
#include <bits/stdc++.h> #define el '\n' #define FNAME "sure" #define allof(x) x.begin(),x.end() #define allof1(x) x.begin()+1,x.end() #define mset(x,n) memset(x,(n),sizeof(x)) using namespace std; const long long MOD = (long long) 1e9+7; template<class X,class Y> bool minimize(X &a,Y b){ if (a>b) {a=b; return true;} return false;} template<class X,class Y> bool maximize(X &a,Y b){ if (a<b) {a=b; return true;} return false;} void setup(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if (fopen(FNAME".inp","r")){ freopen(FNAME".inp","r",stdin); freopen(FNAME".out","w",stdout); } } int n; vector<double> a,b; void init(){ cin>>n; a.resize(n); b.resize(n); for (int i=0;i<n;i++) cin>>a[i]>>b[i]; } void sol(){ sort(a.rbegin(),a.rend()); sort(b.rbegin(),b.rend()); int ptrA=0,ptrB=0; double curA=0.0 ,curB=0.0,res=0.0; for (int i=1;i<=2*n;i++){ if (curA < curB){ if (ptrA==n) break; curA += a[ptrA++]; } else{ if (ptrB==n) break; curB += b[ptrB++]; } maximize(res,min(curA,curB) - i); } cout<<fixed<<setprecision(4)<<res; } int main(){ setup(); init(); sol(); }

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

sure.cpp: In function 'void setup()':
sure.cpp:16:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |                 freopen(FNAME".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:17:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |                 freopen(FNAME".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...