답안 #1037429

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037429 2024-07-28T20:37:41 Z DeathIsAwe Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
    int n; cin >> n;
    vector<pair<int,int>> arts(n);
    for (int i=0;i<n;i++) {
        cin >> arts[i].first >> arts[i].second;
    }
    sort(arts.begin(), arts.end());
    


    int total = 0, ans = arts[0].second, leftsum = arts[0].second;
    priority_queue<int> diffs;
    for (int i=1;i<n;i++) {
        diffs.push(arts[i].first - arts[i-1].first - arts[i-1].second);
        leftsum += arts[i].second - (arts[i].first - arts[i-1].first);
        //cout << ans << ' ' << diffs.top() << '\n';
        ans = max(ans, leftsum + max((int)0, diffs.top()));
    }
    cout << ans;
}

Compilation message

art.cpp: In function 'int32_t main()':
art.cpp:15:9: warning: unused variable 'total' [-Wunused-variable]
   15 |     int total = 0, ans = arts[0].second, leftsum = arts[0].second;
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -