Submission #956952

# Submission time Handle Problem Language Result Execution time Memory
956952 2024-04-02T17:54:41 Z FEDIKUS Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_N = 100100;
 
int n;
double A[MAX_N], B[MAX_N];
 
int main()
{
    // Ulaz
    cin>>n;
 
    for(int i=0;i<n;i++)
    {
        cin>>A[i]>>B[i];
    }
 
    // Obrada
    sort(A, A+n);
    sort(B, B+n);
 
    double rez = 0;
    double profit = 0, loss = 0;
    double sumA = 0, sumB = 0;
    int a = n-1, b = n-1;
    while(a != -1 and b != -1)
    {
        loss++;
 
        if(sumA <= sumB)
        {
          if(a==-1) break;
            sumA += A[a];
           
            a--;
        }
        else
        {
          if(b==-1) break;
            sumB += B[b];

            b--;
        }
 
        if(min(sumA,sumB) - loss > rez)
        {
            rez = min(sumA,sumB) - loss;
        }
    }
 
    // Izlaz
    cout<<rez<<endl;
 
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:25:12: warning: unused variable 'profit' [-Wunused-variable]
   25 |     double profit = 0, loss = 0;
      |            ^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -