Submission #958374

#TimeUsernameProblemLanguageResultExecution timeMemory
958374leo_2727Art Exhibition (JOI18_art)C++17
100 / 100
153 ms31000 KiB
#include <algorithm> #include <fstream> #include <vector> #include <queue> #include <stack> #include <iostream> #include <cmath> #include <queue> #include <set> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <unordered_set> #define F first #define S second #define PB push_back using namespace std; const long long MOD=1e9+7, INF=1e18; const int INFI=1e9; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ii> vii; typedef vector<pair<int, ii>> viii; typedef vector<vii> vvii; typedef vector<ll> vll; typedef vector<vll> vvll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; vll pref(n+1, 0); vector<pair<ll, ll>> info(n); for(auto &num:info) cin>>num.F>>num.S; sort(info.begin(), info.end()); for(int i=1;i<=n;i++) pref[i]+=pref[i-1]+info[i-1].S; ll ans=0; priority_queue<ll> pq; for(int i=0;i<n;i++){ ll start=-pref[i]+info[i].F, end=pref[i+1]-info[i].F; pq.push(start); //cout<<start<<" "<<end<<endl; ans=max(ans, end+pq.top()); } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...