# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
113658 | Akashi | Bali Sculptures (APIO15_sculpture) | C++14 | 216 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
long long x[2005];
int d[2005];
bool dp[105][105];
inline bool check(long long mask){
if(n <= 100){
memset(dp, 0, sizeof(dp));
///can we divide first i elements into j groups
dp[0][0] = 1;
for(int i = 1; i <= n ; ++i){
for(int j = 0; j < i ; ++j){
for(int k = 1; k <= b ; ++k){
if(dp[j][k - 1] && (x[i] - x[j]) - ((x[i] - x[j]) & mask) == 0)
dp[i][k] = 1;
}
}
}
for(int k = a; k <= b ; ++k)
if(dp[n][k]) return 1;
}
else{
memset(d, 0x3f, sizeof(d));
d[0] = 0;
for(int i = 1; i <= n ; ++i){
for(int j = 0; j < i ; ++j){
if(x[i] - x[j] - ((x[i] - x[j]) & mask) == 0)
d[i] = min(d[j] + 1, d[i]);
}
}
if(d[n] <= b) return 1;
}
return 0;
}
int main()
{
scanf("%d%d%d", &n, &a, &b);
for(int i = 1; i <= n ; ++i) scanf("%lld", &x[i]), x[i] += x[i - 1];
long long Sol = (1LL << 63) - 1;
for(long long bit = (1LL << 62); bit >= 1 ; bit >>= 1) if(check(Sol ^ bit)) Sol ^= bit;
printf("%lld", Sol);
return 0;
}
/*
6 1 3
8 1 2 1 5 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |