# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
880237 |
2023-11-29T04:06:41 Z |
niter |
Art Exhibition (JOI18_art) |
C++14 |
|
1000 ms |
98132 KB |
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define entr cerr << endl;
#define spac cerr << ' ';
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) x.begin(), x.end()
#define unilize(x) x.resize(unique(BAE(x)) - x.begin())
#define unisort(x) sort(BAE(x)); unilize(x);
using namespace std;
typedef long long ll;
struct P{
ll A, B;
bool operator<(P x){
return (A == x.A) ? (B < x.B) : (A < x.A);
}
};
const int mxn = (int)(1e5) + 10;
P x[mxn], y[mxn];
int solve(int n){
// int real_ans;
// string ans_mask;
// cin >> real_ans >> ans_mask;
ll ans = -(1e18);
loop(i,1,n+1){
cin >> x[i].A >> x[i].B;
y[i] = x[i];
}
x[0].A = x[0].B = 0;
sort(x + 1, x + n + 1);
ll mx = x[1].A, add = 0;
for(int i = 1; i <= n; i++){
if(i != 1){
mx = max(mx, x[i].A - add);
}
add += x[i].B;
// opa(i) opa(mx) opa(add) op(x[i].A)
ans = max(ans, -x[i].A + mx + add);
}
// if(ans != real_ans){
// opa(ans) op(real_ans)
// op(ans_mask)
// loop(i,1,n+1){
// ops(y[i].A) spac ops(y[i].B) entr
// } entr
// exit(0);
// }
cout << ans;
}
int main(){
// freopen("res.txt", "r", stdin);
ios::sync_with_stdio(false); cin.tie(0);
int n;
while(cin >> n){
solve(n);
break;
}
}
/*
4 81 0110
2 10
42 42
48 45
7 12
3 50 010
2 5
24 50
1 13
*/
Compilation message
art.cpp: In function 'int solve(int)':
art.cpp:59:1: warning: no return statement in function returning non-void [-Wreturn-type]
59 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
98132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
98132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
98132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
98132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |