답안 #1115616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115616 2024-11-20T17:06:07 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;
};

struct triple {
    ll a;
    ll b;
    ll c;
};

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

    ll n; cin >> n;
    vector<dzielo> arts(n);
    for(int 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;});

    ll l = arts[0].s, p = arts[0].s;
    ll s = arts[0].v;
    ll mx = s - p + l;
    for(int i = 1; i < n; i++) {
        l = min(l, arts[i].s);
        p = max(p, arts[i].s);
        s+=arts[i].v;
        mx = max(mx, s - p + l);
        //cout << l << " " << p << " " << s << endl;
    }

    cout << mx;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -