답안 #81556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81556 2018-10-25T10:07:30 Z farukkastamonuda Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000009
#define md 1000000007
#define li 500005
#define mp make_pair
#define pb push_back
using namespace std;
int n,flag;
lo int val,mx;
pair<lo int,lo int> p[li];
vector< pair<lo int,lo int> > v;
priority_queue< pair<lo int,lo int> > q;
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=1;i<=n;i++){
		val+=p[i].se;
		lo int val2=p[i].se;
		while(i<n && p[i+1].fi==p[i].fi){
			val+=p[i+1].se;
			val2+=p[i+1].se;
			i++;
		}
		v.push_back(mp(p[i].fi,val2));
		mx=max(mx,val-(p[i].fi-p[1].fi));
		q.push(mp(val-(p[i].fi-p[1].fi),p[i].fi));
	}
	for(int i=0;i<(int)v.size();i++){
		if(i==0) continue;
		lo int go=v[i].fi;
		//int deg=v[i].se;
		lo int extra=-v[i-1].se+go-v[i-1].fi;
		while(!q.empty()){
			pair<lo int,lo int> temp=q.top();
			q.pop();
			if(temp.se<go) continue;
			mx=max(mx,temp.fi+extra);
			break;
		}
	}
	printf("%lld\n",mx);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
art.cpp:19: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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -