이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |