Submission #580898

#TimeUsernameProblemLanguageResultExecution timeMemory
580898webSure Bet (CEOI17_sure)C++17
0 / 100
1 ms296 KiB
#include <bitset> #include <unordered_map> #include <unordered_set> #include <map> #include <algorithm> #include <string> #include <set> #include <vector> #include <iostream> using namespace std; void output(double p1, double p2) { if(p1 < 0 ||p2<0) printf("%.4lf", (double)(0)); else printf("%.4lf", (double)(min(p1, p2))); } 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()) { output(profit1, profit2); return 0; } //advance second while(profit1 -1 >= profit2 ) { profit1--; profit2 += *(odd2It)-1; odd2It++; if(odd2It == odds2.rend()) { output(profit1, profit2); return 0; } } } else { if(odd1It == odds1.rend()) { output(profit1, profit2); return 0; } //advance first while(profit2 -1 >= profit1 ) { profit2--; profit1 += *(odd1It)-1; odd1It++; if(odd1It == odds1.rend()) { output(profit1, profit2); return 0; } } } output(profit1, profit2); return 0; }

Compilation message (stderr)

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