Submission #1116462

# Submission time Handle Problem Language Result Execution time Memory
1116462 2024-11-21T16:50:57 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <unordered_map>
using namespace std;

typedef long long ll;

struct dzielo {
    ll s;
    ll v;
};



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n; cin >> n;
    vector<dzielo> arts(n);
    for(ll i = 0; i < n; i++) {
        ll s, v; cin >> s >> v;
        arts[i].s = s; arts[i].v = v;
    }
    sort(arts.begin(), arts.end(), [](dzielo a, dzielo b) {return a.s < b.s;});

    vector<ll> wn(n);
    wn[0] = arts[0].v;
    for(int i = 1; i < n; i++) {
        wn[i] = arts[i].v + arts[i - 1].s - arts[i].s;
        //cout << wn[i] << " ";
    }
    //cout << endl;

    ll c = 0;
    ll mx = 0;
    for(int i = 0; i < n; i++) {
        c += wn[i];
        c = max((ll)0, c);
        mx = max(mx, c);
    }

    cout << mx;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -