제출 #125621

#제출 시각아이디문제언어결과실행 시간메모리
125621gs14004Art Exhibition (JOI18_art)C++17
100 / 100
268 ms21028 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> pi;
const int MAXN = 500005;

int n;
pi a[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%lld %lld",&a[i].first,&a[i].second);
	sort(a+1, a+n+1);
	for(int i=1; i<=n; i++){
		a[i].second += a[i-1].second;
	}
	lint maxv = -1e18, ans = 0;
	for(int i=1; i<=n; i++){
		maxv = max(maxv, a[i].first - a[i-1].second);
		ans = max(ans, -a[i].first + a[i].second + maxv);
	}
	cout << ans << endl;
}

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

art.cpp: In function 'int main()':
art.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
art.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%lld %lld",&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...