답안 #468760

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468760 2021-08-29T14:28:26 Z wdjpng Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 332 KB
    #include <bits/stdc++.h>
    //#define double double
    #define rep(i,n) for(int i = 0; i < n; i++)
    #define all(a) a.begin(), a.end()
     
    using namespace std;
     
    signed main()
    {
        int n;
        cin>>n;
     
        vector<double>a(n),b(n);
        rep(i,n) cin>>a[i]>>b[i];
     
        sort(all(a));
        sort(all(b));
        reverse(all(a));
        reverse(all(b));
     
        double maxx = 0;
        int off = 2;
        vector<double>sum(2);
        vector<int>point(2,1);
     
        sum[0] = a[0];
        sum[1] = b[0];
     
        while(min(point[0], point[1])<n)
        {
            maxx=max(maxx, min(sum[0], sum[1])-off);
            if((point[0]==n||sum[0]>sum[1])&&(!point[1]==n)) {
                sum[1]+=b[point[1]]; 
                point[1]++;
            }
            else {
                sum[0]+=a[point[0]]; 
                point[0]++;
            }
            off++;
        }
        maxx=max(maxx, min(sum[0], sum[1])-off);
        //cout<<(int)maxx<<".";
        //maxx-=(int)maxx;
        //rep(i,3) 
        //{
        //    maxx*=10;
        //    cout<<(int)maxx;
        //    maxx-=(int)maxx;
        //}
        //maxx*=10;
        //int o = (int)maxx;
        //if(1000*o+499<1000*maxx) o++;
        //cout<<o;
        printf("%.4lf",(double)maxx);
        //cout<<"\n";
    }

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:32:56: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
   32 |             if((point[0]==n||sum[0]>sum[1])&&(!point[1]==n)) {
      |                                                        ^~
sure.cpp:32:47: note: add parentheses around left hand side expression to silence this warning
   32 |             if((point[0]==n||sum[0]>sum[1])&&(!point[1]==n)) {
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -