이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 5e5 + 10;
struct element
{
ll v, s;
bool operator < (const element &e) const
{
return s < e.s;
}
}e[maxn];
int n;
void solve()
{
cin >> n;
for (int i = 1; i <= n; i ++)
{
cin >> e[i].s >> e[i].v;
}
sort(e + 1, e + n + 1);
ll p = 0, b = -1e18, ans = 0;
for (int i = 1; i <= n; i ++)
{
b = max(b, - p + e[i].s);
p = p + e[i].v;
ans = max(ans, p - e[i].s + b);
///cout << b << " " << i << endl;
}
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
# | 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... |