이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
//-----------------------
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mem(f,x) memset(f, x, sizeof(f))
#define __lcm(a, b) (1ll * a * b) / __gcd(a, b)
#define bit(mask, i) ((mask >> i) & 1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define el '\n'
#define F first
#define S second
#define io(x) freopen(x".inp","r",stdin),freopen(x".out","w",stdout)
//-----------------------
const ll INF = 1e18;
const int MOD = 1e9 + 7;
const int MULTI = 0;
const int dx[4] = {0, 0, 1, -1}; //R L D U
const int dy[4] = {1, -1, 0, 0};
//-----AUTHOR trvhung VNG High School for Gifted Student-----
const int maxn = 6e5 + 5;
int n;
pll a[maxn];
void solve() {
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i].F >> a[i].S;
sort(a + 1, a + 1 + n);
ll low, ans, pref; low = ans = pref = 0;
for (int i = 1; i <= n; ++i) {
low = min(low, pref - a[i].F);
pref += a[i].S;
ans = max(ans, pref - a[i].F - low);
}
cout << ans << el;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (!MULTI) solve();
else {
int test; cin >> test;
while (test--) 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... |