Submission #930979

#TimeUsernameProblemLanguageResultExecution timeMemory
930979lftroqArt Exhibition (JOI18_art)C++14
100 / 100
138 ms25680 KiB
/* :-=- :%@@@@@@@@@= .#@@@@@%@%@@@@@@= -@@@@@@@@@@@@@@@@@# .+@@@@@@@@@@@@@@@@@@@@. #@@@@@@@@@@@@@@@@@@@@@% .*@@@@@@@@@@@@@@@@@@@@@@@= / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\ .@@@@@@@@@@@@@@@@@@@@@@@@# | 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-a[i].fi+dp[i]); } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...