이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
:-=-
:%@@@@@@@@@=
.#@@@@@%@%@@@@@@=
-@@@@@@@@@@@@@@@@@#
.+@@@@@@@@@@@@@@@@@@@@.
#@@@@@@@@@@@@@@@@@@@@@%
.*@@@@@@@@@@@@@@@@@@@@@@@= / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\
.@@@@@@@@@@@@@@@@@@@@@@@@# | lftroq ♥ |
+@@@@@@@@@@@%%@@@@@@@@@@@@- \_________/
.%@@@@@@@@@@%##%@@@@@@@@@@@# //
-@@@@@@@@%%%%%%%%%@@@@@@@@@@:
-+- =@@@@@%##%#%##**+#@@@@@@@@@@-
.+++.%@@@%##%%%%%%%#**+##%%@@@@@@+
+=*%@@@#*###%%#=--+=+*##%@@@@@@%.
:*+%@@*+**##*=======+***#@@@@@@@:
=+++**%@###*=++=-==++**#@@@@@@@:
.**===*%@@@##+=**#*==***@@@@@@@@@:
:+++=+*+%%@@%#==+*%#*+=++@@@@@@@@%
.**#*+*+**+%#+=---=***+==*@@@@@@@:
:**#*+=+**@%##*%#++++--=++#@@@@@@@+-::.
=%**###**#@@%*=*%%%%%*==++++%@@@@@@#=-----.
.%@@%***###@@@%*++%%%#*===+=++++%@@@@%*=-----=.
=**##+=+##@@@@=+%+=***#%@#+**++++%@@%+=-------=:
.++===++====@@@@+--==-=#%%%%+++*++++#%+=------==+=.
-++--=++-:::::=#@#----+--*%%*+**+++++++==-----===--+=
:*+=--++-::::::--=-----==-=%==+%%***++=---=---===-=++:
:*+--+=-::::::::---:----+=-=++##***===-::::-+----=*+:
.=--:::.:::-=-::---::--------++--=====-::::--:-==++
:=::::::--::::::--=+-:--++++==++--==:::-:::----==+=
*-:::::::.....:-++++++++++++++=+=---::::===-:------
:+:--:......:-+++++++++++++++++====---:--=-=----:-:=.
:==--:::.:=+++++++++++++++++++++-::===-:-===-----=--:
.+=--:::-:=+++++==++++++++++++++=--:.:-===+-------+=-.
.+==-----::-+++-:+++=====+++++++=--=======--:----==+=.
:+===-----------:-++====+++++++++=--==--+-:------==-::
+=====-::----+-::-+====+++++++++++=---==:-===:-==-==.
:+===========+-::::-----+++++++++++*=--======-=+=-=.
.=========++=-::::::----:::-++++++*+=+======+++==.
.=========-::::::-----:::=+++++**+=+**====-:. .
*======-::::::::-:-----++++++++==++++++-
#======-:::::::::-------++++++++====+++=
=======-:::::::::----:::=+++++++=====+++
=====---:::::::::::------=++++++===+==++=
:===-:--:::::::::::-------+++++++===++=++
.===-:--:::::::::::::-----=+++++====++===.
.+=-::--::::::::::::-:-----++++++====++=+:
.=-:::--::::::::::::-------=+++++===-----+=
.=-:::--:::::::::::---------=++++==-----==+=.
.=-:::---:::::::::::---------+++===-----===++.
.=::::---:::::::-:-----------=++==-:-----===+-
.--:::---:::::::--------------=+=----==--===+-
.=::::---::::::::::-------===--==-------=--==:
.=--::--::::----:---:::::-:----:::-----======-
.=---:--:::---::::::--------------------==++++
*/
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007LL
#define MOD2 998244353LL
#define endl '\n'
#define PI acos(-1)
#define INFINITE 2147483647LL
#define INFINITE2 9223372036854775807
#define llll pair<ll,ll>
#define ldld pair<ld,ld>
#define fi first
#define se second
#define sqrt sqrtl
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
ll dp[500005];
llll a[5000005];
void solve()
{
int n;
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i].fi >> a[i].se;
sort(a+1,a+1+n);
ll s=0,ans=0;
for(int i=1;i<=n;i++)
{
dp[i]=max(dp[i-1],s+a[i].fi);
s+=a[i].se;
ans=max(ans,s-dp[i-1]);
}
cout << ans << endl;
}
int main()
{
fastIO
//freopen("hanhhhh.inp","r",stdin);
//freopen("hanhhhh.out","w",stdout);
int t=1;
//cin >> t;
while(t--)
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... |