답안 #166828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166828 2019-12-04T08:36:03 Z anubhavdhar Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>

#define ll long long int 
#define FOR(i,N) for(i=0;i<N;i++)
#define FORe(i,N) for(i=1;i<=N;i++)
#define FORr(i,a,b) for(i=a;i<b;i++)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>

const ll MAXN = 1e5;
const ll LOGN = 17;
const ll ROOTN = 320;
const ll INF = 1e17+21;
const ll MOD = 1e9 + 7;

using namespace std;

int main()
{
	ll N,i,K,ans = 1,x,y,prev;
	cin>>N;
	ii P[N];
	FOR(i,N)
	{	
		cin>>x>>y;
		ans = max(ans,y);
		P[i] = mp(x,y);
	}
	sort(P,P+N);
	prev = P[0].ss;
	FORe(i,N-1)
	{
		prev = P[i].ss + prev - P[i].ff + P[i-1].ff;
		ans = max(prev,ans);
	}
	cout<<ans;
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:25:9: warning: unused variable 'K' [-Wunused-variable]
  ll N,i,K,ans = 1,x,y,prev;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -