답안 #1028386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028386 2024-07-19T18:32:17 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
60 ms 5204 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
using ld=long double;


void solve(){
    lli n=1;
 //   deb(n);
    cin>>n;
   // deb(n);
    vector<ld> v1(n);
    vector<ld> v2(n);
    for(lli i=0; i<n; ++i){
        cin>>v1[i]>>v2[i];
     //   deb(v1[i]);
       // deb(v2[i]);
    }
    sort(v1.rbegin(), v1.rend());
    sort(v2.rbegin(), v2.rend());
    ld ans=0;
    ld aux=0;
    ld a=0;
    ld b=0;
    lli p1=0;
    lli p2=0;
    while(p1<n || p2<n){
    

        if(a<=b){
            if(p1<n){
                a+=v1[p1];
                p1++;
            }
            else{
                b+=v2[p2];
                p2++;
            }
        }
        else{
            if(p2<n){
                b+=v2[p2];
                p2++;
            }
            else{
                a+=v1[p1];
                p1++;
            }
        }
    //    deb(a);
  //      deb(b);
        aux=min(a,b);
        aux-=(p1+p2);
   //     deb(aux);
        ans=max(ans, aux);
    }
     cout<<setprecision(4)<<fixed<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    lli t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 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 348 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 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 348 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 56 ms 4788 KB Output is correct
18 Correct 54 ms 4952 KB Output is correct
19 Correct 60 ms 4856 KB Output is correct
20 Correct 55 ms 4848 KB Output is correct
21 Correct 58 ms 5204 KB Output is correct
22 Correct 57 ms 4948 KB Output is correct
23 Correct 55 ms 4744 KB Output is correct
24 Correct 59 ms 4944 KB Output is correct
25 Correct 54 ms 4956 KB Output is correct
26 Correct 60 ms 5204 KB Output is correct