Submission #699680

#TimeUsernameProblemLanguageResultExecution timeMemory
699680Mohamed_Kachef06Art Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define A first #define B second signed main(){ int n; cin >> n; pair<int , int> p[n+1]; for (int i = 1 ; i<=n ; i++){ int a , b; cin >> a >> b; p[i] = {a , b}; } sort(p , p+n+1); for (int i = 1 ; i<=n ; i++){ p[i].B += p[i-1].B; } int max = -1e18 , maxind = 0, min = 1e18; for (int i = 1 ; i<=n ; i++){ if (p[i].B - p[i].A > max) { max = p[i].B - p[i].A; maxind =i ;} } for (int i = 1 ; i<=maxind ; i++){ if (p[i-1].B - p[i].A < min) min = p[i-1].B - p[i].A; } cout << max - min << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...