# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875726 |
2023-11-20T11:58:55 Z |
Isam |
Art Exhibition (JOI18_art) |
C++17 |
|
1000 ms |
600 KB |
#include<bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define a first
#define b second
#define pii pair<int, int>
using namespace std;
const int sz = 5005;
const int inf = 1e15 + 7;
int n, ans;
pii c[sz];
struct edge{
int mn, mx;
} t[sz << 2];
inline void push_up(int in){
t[in].mx = max(t[in << 1].mx, t[in << 1 | 1].mx);
t[in].mn = min(t[in << 1].mn, t[in << 1 | 1].mn);
return;
}
void build(int l, int r, int in){
if(l == r){
t[in] = (edge){c[l].a, c[l].a};
return;
}
int mid = l + ((r - l) >> 1);
build(l, mid, in << 1);
build(mid + 1, r, in << 1 | 1);
push_up(in);
return;
}
int get_mn(int l, int r, int in, int L, int R){
if(l > R || r < L) return inf;
if(l >= L && r <= R) return t[in].mn;
int mid = l + ((r - l) >> 1);
return min(get_mn(l, mid, in << 1, L, R), get_mn(mid + 1, r, in << 1 | 1, L, R));
}
int get_mx(int l, int r, int in, int L, int R){
if(l > R || r < L) return -inf;
if(l >= L && r <= R) return t[in].mx;
int mid = l + ((r - l) >> 1);
return max(get_mx(l, mid, in << 1, L, R), get_mx(mid + 1, r, in << 1 | 1, L, R));
}
int pref[sz];
int comp(int mna, int mxa, int s){
return s - (mxa - mna);
}
signed main(){
SPEED;
cin >> n;
for(register int i = 1; i <= n; ++i){
cin >> c[i].a >> c[i].b;
c[i].b *= (-1);
}
sort(c+1, c+n+1);
int l{1};
for(register int i = 1; i <= n; ++i) pref[i] = pref[i - 1] - c[i].b;
build(1, n, 1);
for(register int i = 1; i < n; ++i){
for(register int j = i; j <= n; ++j){
int tmp = comp(get_mn(1, n, 1, i, j), get_mx(1, n, 1, i, j), pref[j] - pref[i-1]);
ans = max(ans, tmp);
}
}
cout << ans << '\n';
return 0;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:63:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
63 | for(register int i = 1; i <= n; ++i){
| ^
art.cpp:69:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
69 | for(register int i = 1; i <= n; ++i) pref[i] = pref[i - 1] - c[i].b;
| ^
art.cpp:71:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
71 | for(register int i = 1; i < n; ++i){
| ^
art.cpp:72:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
72 | for(register int j = i; j <= n; ++j){
| ^
art.cpp:68:9: warning: unused variable 'l' [-Wunused-variable]
68 | int l{1};
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
9 ms |
348 KB |
Output is correct |
13 |
Correct |
10 ms |
496 KB |
Output is correct |
14 |
Correct |
9 ms |
348 KB |
Output is correct |
15 |
Correct |
9 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
344 KB |
Output is correct |
17 |
Correct |
9 ms |
348 KB |
Output is correct |
18 |
Correct |
11 ms |
348 KB |
Output is correct |
19 |
Correct |
10 ms |
496 KB |
Output is correct |
20 |
Correct |
10 ms |
344 KB |
Output is correct |
21 |
Correct |
10 ms |
348 KB |
Output is correct |
22 |
Correct |
9 ms |
492 KB |
Output is correct |
23 |
Correct |
9 ms |
496 KB |
Output is correct |
24 |
Correct |
10 ms |
348 KB |
Output is correct |
25 |
Correct |
9 ms |
500 KB |
Output is correct |
26 |
Correct |
9 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
9 ms |
348 KB |
Output is correct |
13 |
Correct |
10 ms |
496 KB |
Output is correct |
14 |
Correct |
9 ms |
348 KB |
Output is correct |
15 |
Correct |
9 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
344 KB |
Output is correct |
17 |
Correct |
9 ms |
348 KB |
Output is correct |
18 |
Correct |
11 ms |
348 KB |
Output is correct |
19 |
Correct |
10 ms |
496 KB |
Output is correct |
20 |
Correct |
10 ms |
344 KB |
Output is correct |
21 |
Correct |
10 ms |
348 KB |
Output is correct |
22 |
Correct |
9 ms |
492 KB |
Output is correct |
23 |
Correct |
9 ms |
496 KB |
Output is correct |
24 |
Correct |
10 ms |
348 KB |
Output is correct |
25 |
Correct |
9 ms |
500 KB |
Output is correct |
26 |
Correct |
9 ms |
348 KB |
Output is correct |
27 |
Execution timed out |
1039 ms |
600 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
9 ms |
348 KB |
Output is correct |
13 |
Correct |
10 ms |
496 KB |
Output is correct |
14 |
Correct |
9 ms |
348 KB |
Output is correct |
15 |
Correct |
9 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
344 KB |
Output is correct |
17 |
Correct |
9 ms |
348 KB |
Output is correct |
18 |
Correct |
11 ms |
348 KB |
Output is correct |
19 |
Correct |
10 ms |
496 KB |
Output is correct |
20 |
Correct |
10 ms |
344 KB |
Output is correct |
21 |
Correct |
10 ms |
348 KB |
Output is correct |
22 |
Correct |
9 ms |
492 KB |
Output is correct |
23 |
Correct |
9 ms |
496 KB |
Output is correct |
24 |
Correct |
10 ms |
348 KB |
Output is correct |
25 |
Correct |
9 ms |
500 KB |
Output is correct |
26 |
Correct |
9 ms |
348 KB |
Output is correct |
27 |
Execution timed out |
1039 ms |
600 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |