Submission #342966

#TimeUsernameProblemLanguageResultExecution timeMemory
342966alradArt Exhibition (JOI18_art)C++17
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; using ld = long double; using ull = unsigned long long; /* #pragma comment(linker, "/STACK:256000000") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC optimize("-O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */ template <class T> inline T gcd(T a , T b) { return !a ? b : gcd(b % a , a); } template <class T> inline T lcm(T a , T b) { return (a * b) / gcd(a , b) ; } mt19937 rnd(time(0)); #define all(x) x.begin(), x.end() #define debug(x) { cerr << #x << " = " << x << endl; } void solve() { int n; cin >> n; vector<pair<long long, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(all(a)); long long ans = 0ll, sum = 0ll; for (int i = 0; i < n; i++) { sum += a[i].second; ans = max(ans, sum - a[i].first + a[0].first); } cout << ans << '\n'; return; } signed main() { ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); int t = 1; while (t-- > 0) { solve(); } 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...