답안 #865668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865668 2023-10-24T13:37:39 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 2396 KB
/// tree bends in youth
/// 24  .10.2023
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N =2e5+ 5;
const ll NN =2e6 + 5;
const ll INF = -1e1;
const ll MOD = 1e9 + 7;
const ll LG = 18;
const ll k = 316;
double z[N],x[N],pl[N],pr[N];
double pref[N];
void solve(){
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> z[i] >> x[i];
    }
    sort(z + 1,z + n + 1);
    sort(x + 1,x + n + 1);
    reverse(z + 1,z + n + 1);
    reverse(x + 1,x + n + 1);
    for(int i = 1 ; i <= n ; i ++){
        pref[i] = pref[i - 1] + x[i];
    }
    double mx = 0;
    double sumz = 0,l = 1;
    for(int i = 1 ; i <= n ; i ++){
        sumz += z[i];
        while(1){
            double sum = pref[int(l)];
            mx = max(mx,min(sumz,sum) - (l + i));
            //cout << i << " | " << l << " | " << sumz << " | " << sum << '\n';
            if(sum > sumz){
                break;
            }
            l ++;
        }
    }
    cout << mx;
}
main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ll abd= 1;
//    cin >> abd;
    for(ll i = 1;i <= abd;i++){
//        cout << "Case " << i << ":\n";
        solve();
    }
}

Compilation message

sure.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main (){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -