Submission #973851

# Submission time Handle Problem Language Result Execution time Memory
973851 2024-05-02T11:53:00 Z Hectorungo_18 Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 348 KB
#include <iostream>
#include <bits/stdc++.h>
#include <list>
#include <set>
#include <cstdio>

using namespace std;
#define int long long
#define f first
#define s second 
#define all(x) x.begin(), x.end()


void solve(){
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for(int i = 0; i < n; i++) cin >> v[i].f >> v[i].s;

    sort(all(v));

    int ans = v[0].s;


    int bf = v[0].f;
    int cur = v[0].s;

    for(int i = 1; i < n; i++){
        int ad = v[i].s;
        int re = v[i].f-v[i-1].f;
        if(cur+ad-re < 0){
            cur = ad;
            ans = max(ans, cur);
            continue;
        }
        cur+=ad-re;
        ans=max(ans, cur);
    }

    cout << ans << endl;


}


signed main() {
    int t = 1;
    // cin >> t;
    while(t--) solve();

    return 0;
}

Compilation message

art.cpp: In function 'void solve()':
art.cpp:25:9: warning: unused variable 'bf' [-Wunused-variable]
   25 |     int bf = v[0].f;
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -