Submission #580894

# Submission time Handle Problem Language Result Execution time Memory
580894 2022-06-22T05:31:30 Z web Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 212 KB
#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;
}

Compilation message

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
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -