Submission #48457

# Submission time Handle Problem Language Result Execution time Memory
48457 2018-05-13T16:30:53 Z arman_ferdous Art Exhibition (JOI18_art) C++17
10 / 100
9 ms 716 KB
#include <bits/stdc++.h>
using namespace std;

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

void brute(int n) {
	ll ans = 0;
	for(int mask = 1; mask < (1<<n); mask++) {
		ll sum = 0, mini = (ll)1e18, maxi = (ll)-1e18;
		for(int i = 0; i < n; i++) 
			if(mask>>i&1) {
				sum += arr[i].second;
				mini = min(mini, arr[i].first);
				maxi = max(maxi, arr[i].first);
			}
		ans = max(ans, sum - maxi + mini);
	}
	cout << endl << ans << endl;
}

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);
	}
	printf("%lld", ans);*/
	brute(n);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:27: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 Correct 7 ms 376 KB Output is correct
2 Correct 9 ms 468 KB Output is correct
3 Correct 7 ms 468 KB Output is correct
4 Correct 7 ms 480 KB Output is correct
5 Correct 7 ms 576 KB Output is correct
6 Correct 7 ms 576 KB Output is correct
7 Correct 7 ms 628 KB Output is correct
8 Correct 7 ms 680 KB Output is correct
9 Correct 7 ms 680 KB Output is correct
10 Correct 7 ms 680 KB Output is correct
11 Correct 7 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 9 ms 468 KB Output is correct
3 Correct 7 ms 468 KB Output is correct
4 Correct 7 ms 480 KB Output is correct
5 Correct 7 ms 576 KB Output is correct
6 Correct 7 ms 576 KB Output is correct
7 Correct 7 ms 628 KB Output is correct
8 Correct 7 ms 680 KB Output is correct
9 Correct 7 ms 680 KB Output is correct
10 Correct 7 ms 680 KB Output is correct
11 Correct 7 ms 680 KB Output is correct
12 Incorrect 6 ms 716 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 9 ms 468 KB Output is correct
3 Correct 7 ms 468 KB Output is correct
4 Correct 7 ms 480 KB Output is correct
5 Correct 7 ms 576 KB Output is correct
6 Correct 7 ms 576 KB Output is correct
7 Correct 7 ms 628 KB Output is correct
8 Correct 7 ms 680 KB Output is correct
9 Correct 7 ms 680 KB Output is correct
10 Correct 7 ms 680 KB Output is correct
11 Correct 7 ms 680 KB Output is correct
12 Incorrect 6 ms 716 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 9 ms 468 KB Output is correct
3 Correct 7 ms 468 KB Output is correct
4 Correct 7 ms 480 KB Output is correct
5 Correct 7 ms 576 KB Output is correct
6 Correct 7 ms 576 KB Output is correct
7 Correct 7 ms 628 KB Output is correct
8 Correct 7 ms 680 KB Output is correct
9 Correct 7 ms 680 KB Output is correct
10 Correct 7 ms 680 KB Output is correct
11 Correct 7 ms 680 KB Output is correct
12 Incorrect 6 ms 716 KB Output isn't correct
13 Halted 0 ms 0 KB -