Submission #94976

# Submission time Handle Problem Language Result Execution time Memory
94976 2019-01-26T09:32:24 Z psmao Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 500050;

int n;
ll suf[maxn];
struct pic{ll a; ll s;}g[maxn];

bool cmp(pic a, pic b){return a.a < b.a;}
int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	sf("%d",&n);
	fo(i,1,n) sf("%lld%lld",&g[i].a,&g[i].s);
	sort(g+1,g+n+1,cmp);
	fo(i,1,n) g[i].s += g[i-1].s;
	fd(i,n,1) suf[i] = max(suf[i+1], g[i].s - g[i].a);
	ll ans = 0; fo(i,1,n) ans = max(ans, g[i].a - g[i-1].s + suf[i]);
	pf("%lld",ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:46:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d",&n);
    ^
art.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,n) sf("%lld%lld",&g[i].a,&g[i].s);
              ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -