제출 #62225

#제출 시각아이디문제언어결과실행 시간메모리
62225kingpig9Art Exhibition (JOI18_art)C++11
100 / 100
348 ms115196 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAXN = 500010;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

void setmax (ll &a, ll b) {
	if (a < b) {
		a = b;
	}
}

int N;
pll P[MAXN];
ll V[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%lld %lld", &P[i].fi, &P[i].se);
	}
	sort(P + 1, P + N + 1);

	for (int i = N; i >= 1; i--) {
		P[i].fi -= P[i - 1].fi;
	}

	for (int i = 1; i <= N; i++) {
		V[i] = V[i - 1] - P[i].fi + P[i].se;
	}

	ll ans = LLONG_MIN;
	ll suffmx = LLONG_MIN;
	for (int i = N; i >= 1; i--) {
		setmax(suffmx, V[i]);
		setmax(ans, suffmx - V[i] + P[i].se);
	}
	printf("%lld\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
art.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &P[i].fi, &P[i].se);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...