이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// author : a1abay
#define all(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a*b / (__gcd(a, b)))
#define int ll
typedef long long ll;
typedef long double ld;
const int inf = 1e9 + 7;
const int inff = (int)1e18 + 7;
const int sz = 2e5 + 5;
using namespace std;
int n, m;
int a[sz];
vector<int> v;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
vector<array<int, 2>> v(n);
for(int i = 0; i < n; i++)
{
cin >> v[i][0] >> v[i][1];
}
sort(all(v));
vector<int> a;
for(int i = 0; i < n; i++)
{
a.push_back(v[i][1]);
if(i < n - 1)a.push_back(v[i][0] - v[i + 1][0]);
}
int mx = 0, s = 0;
for(int i : a)
{
s += i;
s = max(s, 0LL);
mx = max(mx, s);
}
cout << mx;
}
| # | 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... |