# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1097778 |
2024-10-08T09:12:04 Z |
SulA |
Art Exhibition (JOI18_art) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define bitcount __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<long long,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
struct node {
int sum, suff;
friend node operator+ (node l, node r) {
return {
l.sum + r.sum,
max(r.suff, l.suff + r.sum)
};
}
};
struct segtree {
vector<node> tree;
int offset = 1;
segtree(int n) {
while (offset < n) offset <<= 1;
tree.resize(offset << 1, {0, 0});
}
};
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int n; cin >> n;
pair<int,int> a[n];
for (int i = 0; i < n; cin >> a[i].first >> a[i++].second);
sort(a, a + n);
long long ans = 0;
node thing = {0, (int)-1e18};
for (int i = 0; i < n-1; i++) {
ans = max(ans, a[i].second);
ans = max(ans, a[i].second + thing.suff);
if (i < n-1) thing = thing + (node){-(a[i+1].first - a[i].first) + a[i].second,
-(a[i+1].first - a[i].first) + a[i].second};
}
cout << ans;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:37:52: warning: operation on 'i' may be undefined [-Wsequence-point]
37 | for (int i = 0; i < n; cin >> a[i].first >> a[i++].second);
| ~^~
# |
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 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
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 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
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 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
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 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |