| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 506070 | amukkalir | Bali Sculptures (APIO15_sculpture) | C++17 | 87 ms | 15948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define se second
#define fi first
#define pb push_back
#define wek puts("wekwek")
#define wik puts("-------")
const int nax = 2e3;
const ll INF = (1ll<<42)-1;
int n, a, b;
int dp[nax+5][nax+5];
ll p[nax+5];
ll sum (int l, int r) {
return p[r] - p[l-1];
}
int f(int grup, int idx, ll x) {
if(grup > b) return 0;
if(idx == n+1) {
return (a <= grup && grup <= b);
}
int &ret = dp[grup][idx];
if(~ret) return ret;
ret = 0;
for(int j=idx; j<=n; j++) {
if((x | sum(idx,j)) == x) {
ret |= f(grup+1, j+1, x);
}
}
//cout << grup << " " << idx << " " << ret << endl;
return ret;
}
signed main () {
scanf("%d %d %d", &n, &a, &b);
for(int i=1; i<=n; i++) {
scanf("%lld", &p[i]);
p[i] += p[i-1];
cout << i << " " << p[i] << endl;
}
ll lo = 0, hi = INF;
ll ans = hi;
while(lo <= hi) {
ll mid = (lo+hi)/2;
memset(dp, -1, sizeof dp);
//cout << bitset<64> (mid) << endl;
if(f(0, 1, mid)) {
ans = mid;
hi = mid-1;
} else {
lo = mid+1;
}
}
printf("%lld", ans);
}
/*
*/
컴파일 시 표준 에러 (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... | ||||
