제출 #418280

#제출 시각아이디문제언어결과실행 시간메모리
418280tgehrArt Exhibition (JOI18_art)C++14
100 / 100
218 ms24644 KiB
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++17 -D_GLIBCXX_DEBUG art.cpp -oart && ./art " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fv(i,v) f(i,sz(v))

struct S{ int a,b; };

main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin>>n;
	vc<S> art(n);
	f(i,n) cin>>art[i].a>>art[i].b;
	sort(all(art),[](S x,S y){ return x.a>y.a; });
	vc<int> p(n+1);
	f(i,n) p[i+1]=p[i]+art[i].b;
	int best=0;
	int low=art[0].a;
	f(i,n+1){
		if(i) best=max(best,p[i]+art[i-1].a-low);
		if(i<n) low=min(low,p[i]+art[i].a);
	}
	cout<<best<<'\n';
}

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

art.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...