답안 #127341

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127341 2019-07-09T08:53:58 Z MrUnknown Art Exhibition (JOI18_art) C++11
0 / 100
2 ms 376 KB
/***
 *      __  __            _    _       _
 *     |  \/  |          | |  | |     | |
 *     | \  / |_ __      | |  | |_ __ | | ___ __   _____      ___ __
 *     | |\/| | '__|     | |  | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
 *     | |  | | |     _  | |__| | | | |   <| | | | (_) \ V  V /| | | |
 *     |_|  |_|_|    (_)  \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
 *
 *
 */
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
#define MP make_pair
#define ii pair<ll,ll>
//#define iii pair<int,ii>
#define fi first
#define se second;

int n;
ll a[500005],b[500005],ans=0;
vector<ii> v;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	scanf("%d", &n);
	f(i,1,n) {
		scanf("%lld %lld", &a[i], &b[i]);
		v.push_back(MP(a[i],b[i]));
	}
	sort(v.begin(),v.end());
	ans=-1e18;
	f(i,1,n) {
		a[i]=a[i-1]+v[i-1].se;
		ans=max(ans,a[i]-v[i-1].fi);
	}
	ans+=v[0].fi;
	printf("%lld", ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &a[i], &b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 -