이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
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;
for (int l = 0; l < n; l++) {
long long mn = a[l].first, mx = a[l].first, sum = 0;
for (int r = l; r < n; r++) {
mn = min(mn, a[r].first);
mx = max(mx, a[r].first);
sum += a[r].second;
ans = max(ans, sum - (mx - mn));
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp: In function 'int main()':
art.cpp:17:52: warning: operation on 'i' may be undefined [-Wsequence-point]
17 | for (int i = 0; i < n; cin >> a[i].first >> a[i++].second);
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |