답안 #972271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972271 2024-04-30T10:16:09 Z vjudge1 Art Exhibition (JOI18_art) C++17
10 / 100
1000 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define el "\n"
#define pb push_back
#define pp pop_back
#define pii pair <int, int>
#define pll pair <ll, ll>
#define ibase ios_base::sync_with_stdio(0), cin.tie(0);

const int N = 5e5 + 5, M = 1e3 + 5, pw = 31;
const ll MAX = 1e15, inf = 1e9 + 7;

pair <ll, int> p[N];
//ll sum[N];

void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i].x >> p[i].y;
	}
	ll ans = -MAX;
	for (int i = 1; i < (1ll << n); i++) {
		ll amx = 0, amn = MAX, sum = 0;
		for (int j = 0; j < n; j++) {
			if (((i >> j) & 1)) {
				amx = max(amx, p[j + 1].x);
				amn = min(amn, p[j + 1].x);
				sum += p[j + 1].y;
			}
		}
		ans = max(ans, sum - (amx - amn));
	}
	cout << ans;
}

int main() {
    ibase;
    int T = 1;
//    cin >> T;
    for (int test = 1; test <= T; ++test) {
//        cout << " " << test << ":" << el;
        solve();
        cout << el;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Execution timed out 1071 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Execution timed out 1071 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Execution timed out 1071 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -