답안 #272132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
272132 2020-08-18T09:41:39 Z Halit Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 288 KB
#include <bits/stdc++.h>
#define max(xx,yy) (xx > yy ? xx : yy)
#define min(xx,yy) (xx > yy ? yy : xx)
#define all(x) x.begin(), x.end()
using namespace std;

int main(){	
	int n;
	scanf("%d", &n);
	
	vector< pair<long long, long long> > v;
	for(int i = 0;i < n;++i){
		long long a,b;
		scanf("%lld %lld", &a, &b);
		v.emplace_back(a,b);
	}
	sort(all(v));
	
	long long sum = 0, j = 0, ans = 0;
	for(int i = 0;i < n;++i){
		if(sum < v[i].first - v[i - (i != j)].first){
			j = i;
			sum = 0;
		}
		sum += v[i].second;
		ans = max(ans,sum - (v[i].first - v[j].first));	
	}
	printf("%lld", ans);
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
art.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%lld %lld", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -