Submission #970648

# Submission time Handle Problem Language Result Execution time Memory
970648 2024-04-27T02:17:53 Z Roumak77 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 348 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;

using ll = long long;

/*void solve(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> list_n(n, pair<ll, ll>{0, 0});
    for(ll i = 0; i < n; i++){
        cin >> list_n[i].first;
        cin >> list_n[i].second;
    }


    sort(list_n.begin(), list_n.end());

    ll curr_max = -1E15 - 5;
    for(ll i = 0; i < n; i++){
        ll start = list_n[i].first;
        ll curr = 0;
        for(ll j = i; j < n; j++){
            curr += list_n[j].second;
            curr_max = max(curr_max, curr - list_n[j].first + start);
        }
    }
    cout << curr_max << endl;
}*/

void solve() {
    ll n;
    cin >> n;

    ll curr_max = 0;

    vector<pair<ll, ll>> list_n(n, pair<ll, ll>{0, 0});
    for (ll i = 0; i < n; i++) {
        cin >> list_n[i].first;
        cin >> list_n[i].second;
        curr_max = max(list_n[i].second, curr_max);
    }



    sort(list_n.begin(), list_n.end());

    ll i = 0;
    ll temp_curr = list_n[i].second;
    while(list_n[i + 1].first - list_n[i].first > temp_curr){
        i++;
        temp_curr += list_n[i].second;
        if(i == n - 1){
            break;
        }
    }
    ll curr = 0;
    ll start = list_n[i].first;
    for(ll j = i; j < n; j++){
        curr += list_n[j].second;
        curr_max = max(curr_max, curr - list_n[j].first + start);
    }

    cout << curr_max << endl;

}


int main(){

    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);

    ll t = 1;

    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -