Submission #1321917

#TimeUsernameProblemLanguageResultExecution timeMemory
1321917vuqar_bazarov1Art Exhibition (JOI18_art)C++20
0 / 100
0 ms332 KiB
/* * * author: attacker * * created: 08.02.2026 17:56:27 */ #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif #define mt_rng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<pair<int64_t, int64_t>> a(n); for (auto& [w, v] : a) { cin >> w >> v; } sort(a.begin(), a.end(), [&](pair<int64_t, int64_t> x, pair<int64_t, int64_t> y) { auto [wx, vx] = x; auto [wy, vy] = y; return (vx - wx) > (vy - wy); }); int64_t ans = 0; int64_t s = 0, mx = -1, mn = int64_t(1e18); for (int i = 0; i < n; i++) { auto [w, v] = a[i]; mx = max(mx, w); mn = min(mn, w); s += v; ans = max(ans, s - mx + mn); } cout << ans << '\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...