이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n;
vector<long long> p;
vector<pair<long long, int>> a;
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++){
int y;
long long x;
cin >> x >> y;
a.push_back({x, y});
}
sort(a.begin(), a.end());
p.resize(n, 0ll);
for(int i = 0; i < n; i ++){
if(i > 0) p[i] = p[i - 1];
p[i] += a[i].second;
}
long long mx = 0ll;
for(int i = 0; i < n; i ++){
for(int j = i; j < n; j ++){
long long sum = p[j];
if(i > 0) sum -= p[i - 1];
mx = max(mx, sum - (a[j].first - a[i].first));
}
}
cout << mx << "\n";
}
# | 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... |