# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
91577 | Mercenary | Bali Sculptures (APIO15_sculpture) | C++11 | 76 ms | 1932 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define taskname "TEST"
#define pb push_back
typedef long double ld;
typedef long long ll;
const int maxn1 = 105;
const int maxn2 = 2e3 + 5;
int n , a , b , y[maxn2];
ll s[maxn2];
void enter()
{
cin >> n >> a >> b;
for(int i = 1 ; i <= n ; ++i){
cin >> y[i];
s[i] = s[i - 1] + y[i];
}
}
ll get(int i , int j)
{
return s[j] - s[i - 1];
}
bool ok(ll x , ll y)
{
return !(x & y);
}
struct Sub1
{
bool f[maxn1][maxn1];
// f(i,j) chon den thg i va dk j nhom
void init(){memset(f,0,sizeof f / sizeof(f[0][0]));}
bool can(ll need)
{
f[0][0] = 1;
for(int i = 1 ; i <= n ; ++i)
{
for(int j = 1 ; j <= b ; ++j)
{
for(int t = i ; t >= 1 && !f[i][j] ; --t)
if(ok(get(t,i),need))f[i][j] |= f[t - 1][j - 1];
}
}
for(int i = a ; i <= b ; ++i)if(f[n][i])return 1;
return 0;
}
}Sub1;
struct Sub2
{
const int inf = 1e9;
int f[maxn2];
void init(){for(int i = 1 ; i <= n ; ++i)f[i] = inf;}
bool can(ll need)
{
for(int i = 1 ; i <= n ; ++i)
for(int t = i ; t >= 1 ; --t)
if(ok(get(t,i),need))f[i] = min(f[i] , f[t - 1] + 1);
return f[n] <= b;
}
}Sub2;
void solve()
{
ll res = 0;
for(int i = 40 ; i >= 0 ; --i)
{
if(a == 1)
{
Sub2.init();
if(Sub2.can(res | (1ll << i)))res |= (1ll << i);
}
else
{
Sub1.init();
if(Sub1.can(res | (1ll << i)))res |= (1ll << i);
}
}
cout << ((~res) & ((1ll << 41) - 1));
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r"))
freopen(taskname".INP", "r",stdin) ,
freopen(taskname".OUT", "w",stdout);
enter();
solve();
}
컴파일 시 표준 에러 (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... |