제출 #580894

#제출 시각아이디문제언어결과실행 시간메모리
580894webSure Bet (CEOI17_sure)C++17
0 / 100
0 ms212 KiB
#include <bitset> #include <unordered_map> #include <unordered_set> #include <map> #include <algorithm> #include <string> #include <set> #include <vector> #include <iostream> using namespace std; int main() { int n; cin>>n; vector<double> odds1(n), odds2(n); for(int i = 0; i<n; ++i) { cin>>odds1[i]>>odds2[i]; } sort(odds1.rbegin(), odds1.rend()); sort(odds2.rbegin(), odds2.rend()); int currInvested = 0; auto odd1It = odds1.rbegin()+1; auto odd2It = odds2.rbegin()+1; double profit1 = odds1[0]-2; double profit2 = odds2[0]-2; while(true) { if(odd1It == odds1.rend()|| odd2It == odds2.rend()) break; //advance both until it is no longer locally optimal if(profit1-2 + *(odd1It) >= profit1 && profit2 -2 + *(odd2It) >= profit2) { profit1 += -2 + *(odd1It); profit2 += -2 + *(odd2It); odd1It++; odd2It++; } else { break; } } // cout<<"zwischnerg. : "<<profit1<<" "<<profit2<<endl; //only advance one if(profit1 > profit2) { if(odd2It == odds2.rend()) { printf("%.4lf", (double)(min(profit1, profit2))); return 0; } //advance second while(profit1 -1 >= profit2 ) { profit1--; profit2 += *(odd2It); odd2It++; if(odd2It == odds2.rend()) { printf("%.4lf", (double)(min(profit1, profit2))); return 0; } } } else { if(odd1It == odds1.rend()) { printf("%.4lf", (double)(min(profit1, profit2))); return 0; } //advance first while(profit2 -1 >= profit1 ) { profit2--; profit1 += *(odd1It); odd1It++; if(odd1It == odds1.rend()) { printf("%.4lf", (double)(min(profit1, profit2))); return 0; } } } printf("%.4lf", (double)(min(profit1, profit2))); return 0; }

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

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