답안 #260984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260984 2020-08-11T09:07:27 Z atoiz Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 416 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <numeric>

using namespace std;

int A, B, N;
vector<int64_t> Y;

bool check(int64_t banned)
{
	if (A == 1) {
		vector<int> dist(N + 1, B + 1);
		dist[0] = 0;
		for (int i = 0; i < N; ++i) if (dist[i] <= B) {
			int64_t cur = 0;
			for (int j = i + 1; j <= N && cur < banned; ++j) {
				cur += Y[j];
				if (!(cur & banned)) dist[j] = min(dist[j], dist[i] + 1);
			}
		}
		return dist[N] <= B;
	} else {
		vector<vector<int>> valid(B + 1, vector<int>(N + 1, 0));
		valid[0][0] = 1;
		for (int i = 0; i < B; ++i) {
			for (int j = 0; j < N; ++j) if (valid[i][j]) {
				int64_t cur = 0;
				for (int k = j + 1; k <= N && cur < banned; ++k) {
					cur += Y[k];
					if (!(cur & banned)) valid[i + 1][k] = true;
				}
			}
		}

		for (int i = A; i <= B; ++i) if (valid[i][N]) return true;
		return false;
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> A >> B;
	Y.resize(N + 1, 0);
	for (int i = 1; i <= N; ++i) cin >> Y[i];

	int log = __lg(accumulate(Y.begin(), Y.end(), 0ll));
	int64_t banned = 0;
	for (int j = log; j >= 0; --j) {
		if (check(banned ^ (1ll << j))) banned ^= (1ll << j);
	}

	cout << (1ll << (log + 1)) - 1 - banned << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 416 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 288 KB Output isn't correct
6 Halted 0 ms 0 KB -