Submission #635754

#TimeUsernameProblemLanguageResultExecution timeMemory
635754kabikaArt Exhibition (JOI18_art)C++14
100 / 100
670 ms42472 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr ll MOD = 1e9 + 7; #define pb push_back #define pli pair<ll,int> #define pr make_pair #define ft first #define sd second int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; map<ll,ll> mp; for(int i = 0; i < n; ++i) { ll a, b; cin >> a >> b; mp[a] += b; } int sz = static_cast<int>(mp.size()); ll mn = mp.begin()->ft, mx = mp.begin()->ft; ll val = 0; vector<ll> dp(sz+1,0); int i = 1; for(auto it = mp.begin(); it != mp.end(); ++it, ++i) { mx = it->ft; val += it->sd; ll tmp1 = val - (mx-mn); if(tmp1 <= it->sd) { dp[i] = it->sd; val = it->sd; mn = mx = it->ft; continue; } dp[i] = tmp1; } sort(dp.begin()+1,dp.end()); cout << dp[sz] << '\n'; 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...