제출 #163425

#제출 시각아이디문제언어결과실행 시간메모리
163425iefnah06Art Exhibition (JOI18_art)C++11
100 / 100
338 ms20984 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const ll INF = 4e18;
const int MAXN = 6e5;
int N;
pair<ll, int> A[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld %d", &A[i].first, &A[i].second);
	}
	sort(A, A + N);
	ll ma = -INF;
	ll ans = -INF;
	ll pref = 0;
	for (int i = 0; i < N; i++) {
		ma = max(ma, A[i].first - pref);
		pref += A[i].second;
		ans = max(ans, pref - A[i].first + ma);
	}
	printf("%lld\n", ans);

	return 0;
}

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

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