Submission #878681

# Submission time Handle Problem Language Result Execution time Memory
878681 2023-11-25T05:03:30 Z Sir_Ahmed_Imran Sure Bet (CEOI17_sure) C++17
100 / 100
74 ms 5532 KB
                            ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define panic break 
#define pii pair<int,int>
#define pic pair<int,char>
#define all(x) (x).begin(),(x).end()
#define sum(a) accumulate(all(a),0)
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define terminator main
#define N 2001
ld prex[N];
ld prey[N];
void solve(){
    int n,l,r;
    ld o,p,q;
    cin>>n;
    vector<ld> x,y;
    for(int i=0;i<n;i++){
        cin>>p>>q;
        x.append(p);
        y.append(q);
    }
    sort(all(x));
    sort(all(y));
    reverse(all(x));
    reverse(all(y));
    for(int i=o=l=r=p=q=0;i<2*n;i++){
        if(p<=q){
            if(l==n) break;
            p+=x[l];
            l++;
        }
        else{
            if(r==n) break;
            q+=y[r];
            r++;
        }
        o=max(o,min(p,q)-i-1);
    }
    cout<<o;
}
int terminator(){
    L0TA;
    cout<<fixed<<setprecision(4);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 70 ms 3784 KB Output is correct
18 Correct 70 ms 5052 KB Output is correct
19 Correct 71 ms 5056 KB Output is correct
20 Correct 71 ms 5172 KB Output is correct
21 Correct 74 ms 5304 KB Output is correct
22 Correct 70 ms 5048 KB Output is correct
23 Correct 71 ms 5168 KB Output is correct
24 Correct 71 ms 5044 KB Output is correct
25 Correct 70 ms 5008 KB Output is correct
26 Correct 74 ms 5532 KB Output is correct