Submission #956957

# Submission time Handle Problem Language Result Execution time Memory
956957 2024-04-02T17:59:13 Z FEDIKUS Sure Bet (CEOI17_sure) C++17
100 / 100
108 ms 3728 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 or 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<<fixed<<showpoint<<setprecision(4)<<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 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 2 ms 360 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 2 ms 360 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 90 ms 3112 KB Output is correct
18 Correct 91 ms 3216 KB Output is correct
19 Correct 108 ms 3352 KB Output is correct
20 Correct 92 ms 3168 KB Output is correct
21 Correct 102 ms 3728 KB Output is correct
22 Correct 92 ms 3168 KB Output is correct
23 Correct 91 ms 3168 KB Output is correct
24 Correct 94 ms 3152 KB Output is correct
25 Correct 92 ms 3152 KB Output is correct
26 Correct 102 ms 3720 KB Output is correct