답안 #66729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66729 2018-08-12T07:45:31 Z ekrem Art Exhibition (JOI18_art) C++
0 / 100
2 ms 252 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].st;
	cvp -= q[bas].nd;
	cvp -= mx - mn;
	return cvp > yed;
}

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

void ekle(ll a, ll b){
	cvp += mx - mn;
	mx = a;
	cvp += b;
	cvp -= mx - mn;
	ans = max(ans, cvp);
	while(sz() >= 1)
		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:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
art.cpp:43: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 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -