이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<ll, ll>
#define ld long double
#define nl endl
#define tb '\t'
#define sp ' '
#define sqr(x) (x)*(x)
using namespace std;
const ll MX=2002, MOD=1000000007, BLOCK=327, INF=2e9+7;
const ll INFF=1000000000000000007;
const ld ERR=1e-6, pi=3.14159265358979323846;
ll N, L, R, A[MX], pref[MX], DP[105][2005], ans=INF;
ll getp(ll le, ll ri){
return pref[ri]-pref[le-1];
}
int main(){
fastio;
cin >> N >> L >> R;
for(ll i=0; i<=102; i++)
for(ll j=0; j<=2002; j++)
DP[i][j]=INF;
for(ll i=1; i<=N; i++){
cin >> A[i];
pref[i]=pref[i-1]+A[i];
}
DP[1][0]=0;
for(ll i=1; i<=N; i++){
for(ll j=0; j<=2000; j++){
for(ll k=i; k<=N; k++){
ll tmp=(j|getp(i, k));
DP[k+1][tmp]=min(DP[k+1][tmp], DP[i][j]+1);
}
}
}
for(ll i=0; i<=2000; i++){
if(DP[N+1][i]>=L && DP[N+1][i]<=R){
cout << i << nl;
return 0;
}
}
}
# | 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... |