Submission #1108370

#TimeUsernameProblemLanguageResultExecution timeMemory
1108370vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
130 ms18440 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, s[N], ans;
pll p[N];
priority_queue<ll> pq;
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++)
        s[i] = s[i-1] + p[i].se;
    pq.push(0);
    for (int i= 1; i<= n; i++) {
        pq.push(p[i].fi - s[i-1]);
        ans = max(ans, s[i] - p[i].fi + pq.top());
    }
    cout<<ans;
}


Compilation message (stderr)

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