제출 #1156831

#제출 시각아이디문제언어결과실행 시간메모리
1156831gulmixArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; using ll = long long; #define all(x) x.begin(), x.end() #define oset tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> int main(){ ios::sync_with_stdio(false); cin.tie(0); //ifstream cin("inputf.txt"); //ofstream cout("outputfv.txt"); ll n; cin >> n; vector<pair<ll, ll>> a(n); for(int i = 0; i < n; i++){ cin >> a[i].first >> a[i].second; } sort(all(a)); ll cur = 0; ll ans = 0; ll mn = a[0].first, mx = a[0].first; for(int i = 0; i < n; i++){ mn = min(a[i].first, mn); mx = max(a[i].first, mx); cur += a[i].second; if(cur - (mx - mn) < 0){ cur = 0; mn = a[i].first; mx = a[i].first; i--; continue; } ans = max(ans, cur - (mx - mn)); } cout << ans << '\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...