Submission #1108373

#TimeUsernameProblemLanguageResultExecution timeMemory
1108373vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
125 ms8272 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
const ll N = 5e5+5;
ll n, ans, mx;
pll p[N];
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "task"
    if (fopen(task".INP", "r")) {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
    if (fopen("task.INP", "r")) {
        freopen("task.INP", "r", stdin);
        freopen("task.OUT", "w", stdout);
    }
    cin>>n;
    for (int i= 1; i<= n; i++)
        cin>>p[i].fi>>p[i].se;
    sort(p+1, p+n+1);
    for (int i= 1; i<= n; i++) {
        p[i].se += p[i-1].se;
        mx = max(mx, p[i].fi - p[i-1].se);
        ans = max(ans, p[i].se - p[i].fi + mx);
    }
    cout<<ans;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen(task".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(task".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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("task.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen("task.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...