Submission #48460

# Submission time Handle Problem Language Result Execution time Memory
48460 2018-05-13T17:22:47 Z arman_ferdous Art Exhibition (JOI18_art) C++17
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 5e5+10;
pair<ll,ll> arr[N];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%lld %lld", &arr[i].first, &arr[i].second);

	sort(arr,arr+n);
	ll ans = 0, sum = 0;
	for(int i = 0; i < n; i++) {
		sum += arr[i].second;
		ans = max(ans, sum - arr[i].first + arr[0].first);
	}
	sum = 0;
	for(int i = n-1; i >= 0; i--) {
		sum += arr[i].second;
		ans = max(ans, sum - arr[n-1].first + arr[i].first);
	}
	printf("%lld", ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &arr[i].first, &arr[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -