답안 #572501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572501 2022-06-04T14:08:32 Z urosk Sure Bet (CEOI17_sure) C++14
100 / 100
94 ms 6752 KB
//https://oj.uz/problem/view/CEOI17_sure
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;

#define maxn 100005
ll n;
vector<ld> v,w;
bool cmp(ld x,ld y){return x>y;}
ld reshi(vector<ld> a,vector<ld> b){
    ld ans = 0;
    ld suma = 0;
    ld sumb = 0;
    ll j = 1;
    for(ll i = 1;i<=n;i++){
        suma+=a[i];
        while(j<=n&&sumb+b[j]<=suma){
            sumb+=b[j];
            ans = max(ans,sumb-i-j);
            j++;
        }
    }
    return ans;
}
int main(){
	daj_mi_malo_vremena
    cin >> n;
    v.resize(n+1);
    w.resize(n+1);
    for(ll i = 1;i<=n;i++){
        cin >> v[i] >> w[i];
    }
    sort(v.begin()+1,v.end(),cmp);
    sort(w.begin()+1,w.end(),cmp);
    ld ans = max(reshi(v,w),reshi(w,v));
    cout<<fixed<<setprecision(4);
    cout<<ans<<endl;
    return 0;
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 328 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 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 328 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 2 ms 340 KB Output is correct
17 Correct 77 ms 6348 KB Output is correct
18 Correct 75 ms 6360 KB Output is correct
19 Correct 81 ms 6352 KB Output is correct
20 Correct 75 ms 6328 KB Output is correct
21 Correct 85 ms 6752 KB Output is correct
22 Correct 78 ms 6324 KB Output is correct
23 Correct 75 ms 6324 KB Output is correct
24 Correct 80 ms 6604 KB Output is correct
25 Correct 77 ms 6364 KB Output is correct
26 Correct 94 ms 6696 KB Output is correct