답안 #66732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66732 2018-08-12T07:53:28 Z ekrem Art Exhibition (JOI18_art) C++
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
typedef long long ll;

ll n, cvp, mn, mx, ans, bas = 1, son;
pair < ll , ll > a[N], q[N];

bool cikar(){
	ll yed = cvp;
	cvp += mx - mn;
	mn = q[bas + 1].st;
	cvp -= q[bas].nd;
	cvp -= mx - mn;
	if(cvp >= yed)
		return 1;
	cvp = yed;
	mn = q[bas].st;
	return 0;
}

ll sz(){return son - bas + 1;}

void ekle(ll a, ll b){
	cvp += mx - mn;
	mx = a;
	cvp += b;
	cvp -= mx - mn;
	q[++son] = mp(a, b);
	ans = max(ans, cvp);
	while(sz() >= 2)
		if(cikar())
			bas++;
		else
			break;
	ans = max(ans, cvp);
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(ll i = 1; i <= n; i++)
		scanf("%lld %lld",&a[i].st ,&a[i].nd);
	sort(a + 1, a + n + 1);
	mn = a[1].st;
	mx = a[1].st;
	cvp = a[1].nd;
	ans = cvp;
	for(ll i = 2; i <= n; i++)
		ekle(a[i].st, a[i].nd);
	printf("%lld\n",ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
art.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&a[i].st ,&a[i].nd);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -