답안 #238705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238705 2020-06-12T11:52:54 Z dCoding Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 256 KB
#include <bits/stdc++.h>

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define MS(x,a) memset((x),(a),sizeof(x)) 
#define F0R(i,n) for(auto (i) = 0; (i) < (n); (i)++)
#define FOR(i,a,b) for(auto (i) = (a); (i) <= (b); (i)++)
#define ROF(i,a,b) for(auto (i) = (a); (i) >= (b); (i)--)

using namespace std;

const int MAXN = 5e5+5;
pll a[MAXN];
ll pre[MAXN];

int main() {
	int n; scanf("%d",&n);
	FOR(i,1,n) scanf("%lld%lld",&a[i].F,&a[i].S);
	sort(a+1,a+1+n);
	FOR(i,1,n) pre[i] = pre[i-1]+a[i].S;
	ll l = -1e9,sl = -1e9,ans = -1e9;
	FOR(i,1,n) {
		ll v = pre[i]-a[i].F;
		ans = max(ans,v+l);
		v = a[i].F-pre[i-1];
		l = max(l,v);
 	}
 	printf("%lld",ans);
}	

Compilation message

art.cpp: In function 'int main()':
art.cpp:29:14: warning: unused variable 'sl' [-Wunused-variable]
  ll l = -1e9,sl = -1e9,ans = -1e9;
              ^~
art.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d",&n);
         ~~~~~^~~~~~~~~
art.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  FOR(i,1,n) scanf("%lld%lld",&a[i].F,&a[i].S);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -