# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1261323 | phamducluong | Art Exhibition (JOI18_art) | C++20 | 106 ms | 8264 KiB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
using ll=long long;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define mem(a,x) memset(a,x,sizeof(a))
#define int long long
#define fast(s) s.reserve(2000); s.max_load_factor(0.5);
#define F first
#define S second
#define pii pair <int, int>
#define iii tuple<int,int,int>
#define all(p) p.begin(), p.end()
template<typename T> bool maximum(T &A, const T &B) {return A<B? A=B, true: false;}
template<typename T> bool minimum(T &A, const T &B) {return A>B? A=B, true: false;}
const int mod=1e9+7;
const int base=2999;
const int INF=1e18;
const int N=5e5+5, LOG=17;
int n, res=-INF;;
pii a[N];
void file()
{
#define task "main"
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void Solve()
{
cin>>n;
for(int i=1; i<=n; ++i) cin>>a[i].F>>a[i].S;
sort(a+1,a+n+1);
for(int i=1; i<=n; ++i) a[i].S+=a[i-1].S;
int mn=INF;
for(int i=1; i<=n; ++i)
{
minimum(mn,a[i-1].S-a[i].F);
maximum(res,a[i].S-a[i].F-mn);
}
cout<<res;
}
signed main()
{
file();
Solve();
return 0;
}
Compilation message (stderr)
# | 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... |