제출 #1076118

#제출 시각아이디문제언어결과실행 시간메모리
1076118lmaobruhArt Exhibition (JOI18_art)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
#define ii pair<long long, long long>
#define fi first
#define se second
const int N = 5e5+5;
int n;
ii a[N];

bool cmp(ii p1, ii p2) {
    if (p1 == p2) return 0;
    else if (p1 != p2) return p1.fi < p2.fi;
    else return p1.se > p2.se;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("A.inp", "r"))
        freopen("A.inp", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i].fi >> a[i].se;
    sort(a+1, a+n+1, cmp);
    long long ans = a[1].se, mx = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, mx - a[i].fi + a[i].se);
        mx = max(mx + a[i].se, a[i].fi + a[i].se);
    }
    cout << ans;
}

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen("A.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...