제출 #41209

#제출 시각아이디문제언어결과실행 시간메모리
41209adletArt Exhibition (JOI18_art)C++14
100 / 100
681 ms8684 KiB
#include <bits/stdc++.h>

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")

#define name "name"
#define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);

typedef long long ll;

const int N = 5e5 + 5;

int n;

pair < ll, ll> a[N];

int main() {
    file(name);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) {
        a[i].second += a[i - 1].second;
    }
    ll ans = -1e18, mn = -1e18;
    int r = 1;
    while (r <= n) {
        mn = max(mn, a[r].first - a[r - 1].second);
        ans = max(ans, (a[r].second - a[r].first) + mn);
        ++r;
    }
    cout << ans;
}

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

art.cpp:5:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 ^
art.cpp: In function 'int main()':
art.cpp:10:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);
                                                                                              ^
art.cpp:21:5: note: in expansion of macro 'file'
     file(name);
     ^
art.cpp:10:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);
                                                                                              ^
art.cpp:21:5: note: in expansion of macro 'file'
     file(name);
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...