Submission #268863

# Submission time Handle Problem Language Result Execution time Memory
268863 2020-08-17T03:58:36 Z leductoan Art Exhibition (JOI18_art) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
#define task "art"
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define alll(v) (v).begin(),(v).end()
#define szz(v) (v).size()
#define fi first
#define se second
#define pb push_back
#define FOR(i,a,b) for (ll i = (a), _b = (b); i <= _b; ++i)
#define FORD(i,b,a) for (ll i = (b), _a = (a); i >= _a; --i)
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pii;

const ll MOD=1000000007; /// 998244353
const ll base=311; /// for hash actually
const ll N=5e5+5;

ll n,b[N];
pii a[N];
void solved()
{
    cin>>n;
    FOR(i,1,n) cin>>a[i].fi>>a[i].se;
    sort(a+1,a+n+1);
    ll ans=0;
    FOR(i,1,n) ans=max(ans,a[i].se);
    b[1]=a[1].se;
    FOR(i,2,n) b[i]=a[i].se-(a[i].fi-a[i-1].fi);
//    FOR(i,1,n) cout<<b[i]<<' ';
//    cout<<endl;
    ll s=0;
    FOR(i,1,n)
    {
        if(s<0) s=0;
        s+=b[i];
        ans=max(ans,s);
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solved();
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   49 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   50 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -