Submission #868917

#TimeUsernameProblemLanguageResultExecution timeMemory
868917rockstarArt Exhibition (JOI18_art)C++17
100 / 100
236 ms44620 KiB
// #pragma GCC optimize("O3,unroll-loops,inline,no-stack-protector") // #pragma GCC target("avx,avx2,sse3,ssse3,sse4.1,sse4.2,fma,bmi2,abm,popcnt,mmx,tune=native") #include <bits/stdc++.h> using namespace std; #define trace(x) cerr << #x << ": " << (x) << endl; #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() using ll = long long; #define int ll constexpr int INF = numeric_limits<int>::max() / 2; void solve() { int n; cin >> n; vector<pair<int, int>> v(n); for (auto& i : v) cin >> i.first >> i.second; sort(all(v)); set<int> st; int ans = 0, pref = 0; for (int i = 0; i < n; ++i) { st.insert(pref - v[i].first); pref += v[i].second; ans = max(ans, pref - v[i].first - *st.begin()); } cout << ans; } signed main() { #ifdef LOCAL freopen("input.in", "r", stdin); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif int t = 1; // cin >> t; while (t--) solve(); #ifdef LOCAL cerr << '\n' << "time = " << clock() * 1.0 / CLOCKS_PER_SEC << '\n'; #endif 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...