제출 #1321858

#제출 시각아이디문제언어결과실행 시간메모리
1321858aaakkksssiiinnnArt Exhibition (JOI18_art)C++20
50 / 100
1096 ms19808 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define f first #define s second #define pb push_back #define yes cout << "yes" << endl; #define YES cout << "YES" << endl; #define no cout << "no" << endl; #define NO cout << "NO" << endl; void never_give_up() { int n; cin >> n; vector<int>a(n + 1); vector<int>b(n + 1); vector<pair<int, int>>h; for(int i = 1;i <= n; i++){ //cin >> a[i] >> b[i]; int c ,d; cin >> c >> d; h.pb({c, d}); } sort(h.begin(), h.end()); for(int i = 0;i < n; i++){ //cin >> a[i] >> b[i]; a[i + 1] = h[i].f; b[i + 1] = h[i].s; } /*for(int i = 1;i <= n; i++){ cout << a[i] << " "; } cout << endl; for(int i = 1;i <= n; i++){ cout << b[i] << " "; } cout << endl;*/ vector<int>pref(n + 1, 0); for(int i = 1;i <= n; i++){ pref[i] = pref[i - 1] + b[i]; } /*for(int i = 1;i <= n; i++){ cout << pref[i] << " "; } cout << endl;*/ int cvb = LLONG_MIN; for(int i = 1; i < n;i ++){ for(int j = i; j <= n; j++){ /////////////////////////// int say = pref[j] - pref[i - 1]; int mi = a[i]; int ma = a[j]; //cout << i << " : " << j << endl; //cout << say << " | " << mi << " " << ma << endl; cvb = max(cvb, say - (ma - mi)); //cout << endl; /////////////////////////// } } cout << cvb << endl; } void You_can_do_it() { } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int THE_wasd = 1; //cin >> THE_wasd; while(THE_wasd--){ never_give_up(); //You_can_do_it(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...