Submission #769397

#TimeUsernameProblemLanguageResultExecution timeMemory
769397RifalArt Exhibition (JOI18_art)C++14
100 / 100
181 ms24704 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 998244353 #define INF 100000000 //#define ll long long ///#define cin fin ///#define cout fout #define fi first #define se second using namespace std; ///ofstream fout("herding.out"); ///ifstream fin("herding.in"); int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); long long n, ans = 0; cin >> n; pair<long long ,long long> arr[n]; long long dp[n+1]= {}; for(int i = 0; i < n; i++) { cin >> arr[i].first >> arr[i].second; } sort(arr,arr+n); for(int i = 1; i <= n; i++) { dp[i] = max(dp[i-1],arr[i-1].first) + arr[i-1].second; ans = max(ans,dp[i]-arr[i-1].first); } cout << ans; 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...