# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81561 | 2018-10-25T10:21:38 Z | farukkastamonuda | Art Exhibition (JOI18_art) | C++14 | 2 ms | 376 KB |
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 500005 #define mp make_pair #define pb push_back using namespace std; int n,flag; lo int val,mx; pair<lo int,lo int> p[li]; vector< pair<lo int,lo int> > v; priority_queue< pair<lo int,lo int> > q; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld %lld",&p[i].fi,&p[i].se); } sort(p+1,p+n+1); for(int i=1;i<=n;i++){ val+=p[i].se; lo int val2=p[i].se; while(i<n && p[i+1].fi==p[i].fi){ val+=p[i+1].se; val2+=p[i+1].se; i++; } v.push_back(mp(p[i].fi,val2)); mx=max(mx,val-(p[i].fi-p[1].fi)); q.push(mp(val-(p[i].fi-p[1].fi),p[i].fi)); } for(int i=0;i<(int)v.size();i++){ if(i==0) continue; lo int go=v[i].fi; //int deg=v[i].se; lo int extra=-v[0].se+go-v[0].fi; while(!q.empty()){ pair<lo int,lo int> temp=q.top(); q.pop(); if(temp.se<go) continue; mx=max(mx,temp.fi+extra); //q.push(temp); //q.push(mp(temp.fi+extra,go)); break; } } printf("%lld\n",mx); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |