답안 #595082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595082 2022-07-13T10:56:31 Z FEDIKUS Sure Bet (CEOI17_sure) C++17
100 / 100
82 ms 1972 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define ff(i,s,f) for(int (i)=s;(i)<(f);(i)++)
#define fb(i,s,f) for(int (i)=s-1;(i)>=f;(i)--)
#define ffi(i,s,f) for(int (i)=s;(i)<=(f);(i)++)
#define fbi(i,s,f) for(int (i)=s;(i)>=(f);(i)--)
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;

const int maxn=1e5+10;

double a[maxn];
double b[maxn];

void solve(){
    int n;
    cin>>n;
    ff(i,0,n){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n,greater<double>());
    sort(b,b+n,greater<double>());
    double res=0;
    double suma=0,sumb=0;
    int inda=0,indb=0;
    while(true){
        if(suma<sumb){
            if(inda==n) break;
            suma+=a[inda];
            inda++;
        }else{
            if(indb==n) break;
            sumb+=b[indb];
            indb++;
        }
        res=max(res,min(suma,sumb)-inda-indb);
    }
    cout<<fixed<<showpoint<<setprecision(4)<<res<<"\n";
}

int main(){
    ios;
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Compilation message

sure.cpp: In function 'void solve()':
sure.cpp:9:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define ff(i,s,f) for(int (i)=s;(i)<(f);(i)++)
      |                           ^
sure.cpp:35:5: note: in expansion of macro 'ff'
   35 |     ff(i,0,n){
      |     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 69 ms 1872 KB Output is correct
18 Correct 82 ms 1824 KB Output is correct
19 Correct 66 ms 1860 KB Output is correct
20 Correct 66 ms 1856 KB Output is correct
21 Correct 72 ms 1860 KB Output is correct
22 Correct 68 ms 1972 KB Output is correct
23 Correct 70 ms 1812 KB Output is correct
24 Correct 75 ms 1768 KB Output is correct
25 Correct 65 ms 1740 KB Output is correct
26 Correct 72 ms 1808 KB Output is correct