#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 100000000000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
template<class T>
bool operator()(T const &a, T const &b) const { return a > b; }
};
ll x,y,z;
ve hedi,pref;
ll glob=INF;
ll dp[101][101][2002];
ll solve(ll index,ll far,ll now)
{
if(index>=x)
{
if(far>=y && far<=z)
{
return 0;
}
return INF;
}
if(dp[index][far][now]!=-1)return dp[index][far][now];
ll ans=INF;
ll ans1=INF;
for (ll i = 1; i <= x-index; ++i)
{
ll yol = pref[index+i-1]-pref[index-1];
if(index==0)yol=pref[index+i-1];
ll k = (yol|solve(index+i,far+1,yol|now));
if((k|now)<ans)
{
ans=(k|now);
ans1=k;
}
}
return dp[index][far][now]=ans1;
}
int main()
{
//flash;
cin>>x>>y>>z;
ll cur=0;
for (int i = 0; i < 2002; ++i)
{
for (int j = 0; j < 101; ++j)
{
for (int n = 0; n < 101; ++n)
{
dp[n][j][i]=-1;
}
}
}
for (ll i = 0; i < x; ++i)
{
ll yo;cin>>yo;hedi.pb(yo);
cur+=yo;
pref.pb(cur);
}
cout<<solve(0,0,0);
return 0;
}
//code the AC sol !
// BS/queue/map
Compilation message
sculpture.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("O3")
sculpture.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
528 ms |
160272 KB |
Output is correct |
2 |
Correct |
520 ms |
160216 KB |
Output is correct |
3 |
Correct |
537 ms |
160192 KB |
Output is correct |
4 |
Correct |
527 ms |
160236 KB |
Output is correct |
5 |
Correct |
521 ms |
160112 KB |
Output is correct |
6 |
Correct |
551 ms |
160232 KB |
Output is correct |
7 |
Correct |
536 ms |
160376 KB |
Output is correct |
8 |
Correct |
522 ms |
160376 KB |
Output is correct |
9 |
Correct |
523 ms |
160376 KB |
Output is correct |
10 |
Correct |
532 ms |
160372 KB |
Output is correct |
11 |
Correct |
523 ms |
160344 KB |
Output is correct |
12 |
Correct |
527 ms |
160252 KB |
Output is correct |
13 |
Correct |
556 ms |
160348 KB |
Output is correct |
14 |
Correct |
523 ms |
160208 KB |
Output is correct |
15 |
Correct |
526 ms |
160376 KB |
Output is correct |
16 |
Correct |
513 ms |
160204 KB |
Output is correct |
17 |
Correct |
526 ms |
160296 KB |
Output is correct |
18 |
Correct |
523 ms |
160252 KB |
Output is correct |
19 |
Correct |
523 ms |
160184 KB |
Output is correct |
20 |
Correct |
527 ms |
160384 KB |
Output is correct |
21 |
Correct |
528 ms |
160180 KB |
Output is correct |
22 |
Correct |
569 ms |
160300 KB |
Output is correct |
23 |
Correct |
545 ms |
160376 KB |
Output is correct |
24 |
Correct |
555 ms |
160308 KB |
Output is correct |
25 |
Correct |
531 ms |
160320 KB |
Output is correct |
26 |
Correct |
527 ms |
160232 KB |
Output is correct |
27 |
Runtime error |
744 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
525 ms |
160348 KB |
Output is correct |
2 |
Correct |
528 ms |
160432 KB |
Output is correct |
3 |
Correct |
533 ms |
160256 KB |
Output is correct |
4 |
Correct |
529 ms |
160120 KB |
Output is correct |
5 |
Correct |
524 ms |
160120 KB |
Output is correct |
6 |
Correct |
528 ms |
160348 KB |
Output is correct |
7 |
Correct |
534 ms |
160220 KB |
Output is correct |
8 |
Correct |
529 ms |
160132 KB |
Output is correct |
9 |
Correct |
528 ms |
160280 KB |
Output is correct |
10 |
Correct |
522 ms |
160176 KB |
Output is correct |
11 |
Correct |
533 ms |
160220 KB |
Output is correct |
12 |
Correct |
530 ms |
160220 KB |
Output is correct |
13 |
Correct |
527 ms |
160376 KB |
Output is correct |
14 |
Correct |
526 ms |
160220 KB |
Output is correct |
15 |
Correct |
533 ms |
160256 KB |
Output is correct |
16 |
Correct |
523 ms |
160220 KB |
Output is correct |
17 |
Correct |
525 ms |
160256 KB |
Output is correct |
18 |
Correct |
523 ms |
160296 KB |
Output is correct |
19 |
Correct |
527 ms |
160248 KB |
Output is correct |
20 |
Correct |
528 ms |
160356 KB |
Output is correct |
21 |
Correct |
565 ms |
160248 KB |
Output is correct |
22 |
Correct |
526 ms |
160252 KB |
Output is correct |
23 |
Correct |
526 ms |
160124 KB |
Output is correct |
24 |
Correct |
533 ms |
160248 KB |
Output is correct |
25 |
Correct |
535 ms |
160220 KB |
Output is correct |
26 |
Correct |
522 ms |
160248 KB |
Output is correct |
27 |
Correct |
528 ms |
160376 KB |
Output is correct |
28 |
Correct |
537 ms |
160248 KB |
Output is correct |
29 |
Correct |
521 ms |
160252 KB |
Output is correct |
30 |
Correct |
525 ms |
160348 KB |
Output is correct |
31 |
Correct |
540 ms |
160256 KB |
Output is correct |
32 |
Correct |
523 ms |
160248 KB |
Output is correct |
33 |
Correct |
532 ms |
160180 KB |
Output is correct |
34 |
Correct |
530 ms |
160312 KB |
Output is correct |
35 |
Correct |
542 ms |
160224 KB |
Output is correct |
36 |
Correct |
527 ms |
160376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
535 ms |
160248 KB |
Output is correct |
2 |
Correct |
525 ms |
160376 KB |
Output is correct |
3 |
Correct |
521 ms |
160196 KB |
Output is correct |
4 |
Correct |
541 ms |
160248 KB |
Output is correct |
5 |
Correct |
527 ms |
160228 KB |
Output is correct |
6 |
Correct |
524 ms |
160120 KB |
Output is correct |
7 |
Correct |
538 ms |
160304 KB |
Output is correct |
8 |
Correct |
525 ms |
160220 KB |
Output is correct |
9 |
Correct |
530 ms |
160120 KB |
Output is correct |
10 |
Correct |
531 ms |
160476 KB |
Output is correct |
11 |
Correct |
539 ms |
160248 KB |
Output is correct |
12 |
Correct |
526 ms |
160272 KB |
Output is correct |
13 |
Correct |
523 ms |
160248 KB |
Output is correct |
14 |
Correct |
533 ms |
160404 KB |
Output is correct |
15 |
Correct |
522 ms |
160248 KB |
Output is correct |
16 |
Correct |
546 ms |
160280 KB |
Output is correct |
17 |
Correct |
554 ms |
160328 KB |
Output is correct |
18 |
Correct |
533 ms |
160248 KB |
Output is correct |
19 |
Correct |
536 ms |
160260 KB |
Output is correct |
20 |
Correct |
522 ms |
160376 KB |
Output is correct |
21 |
Correct |
524 ms |
160232 KB |
Output is correct |
22 |
Correct |
522 ms |
160248 KB |
Output is correct |
23 |
Correct |
546 ms |
160244 KB |
Output is correct |
24 |
Correct |
526 ms |
160240 KB |
Output is correct |
25 |
Correct |
531 ms |
160248 KB |
Output is correct |
26 |
Correct |
545 ms |
160248 KB |
Output is correct |
27 |
Correct |
563 ms |
160236 KB |
Output is correct |
28 |
Correct |
614 ms |
160440 KB |
Output is correct |
29 |
Correct |
578 ms |
160268 KB |
Output is correct |
30 |
Correct |
569 ms |
160328 KB |
Output is correct |
31 |
Correct |
591 ms |
160308 KB |
Output is correct |
32 |
Correct |
600 ms |
160380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
519 ms |
160128 KB |
Output is correct |
2 |
Correct |
524 ms |
160324 KB |
Output is correct |
3 |
Correct |
530 ms |
160248 KB |
Output is correct |
4 |
Correct |
570 ms |
160376 KB |
Output is correct |
5 |
Correct |
524 ms |
160152 KB |
Output is correct |
6 |
Correct |
521 ms |
160180 KB |
Output is correct |
7 |
Correct |
526 ms |
160248 KB |
Output is correct |
8 |
Correct |
524 ms |
160376 KB |
Output is correct |
9 |
Correct |
513 ms |
160248 KB |
Output is correct |
10 |
Correct |
515 ms |
160268 KB |
Output is correct |
11 |
Correct |
521 ms |
160396 KB |
Output is correct |
12 |
Correct |
516 ms |
160244 KB |
Output is correct |
13 |
Correct |
515 ms |
160256 KB |
Output is correct |
14 |
Correct |
515 ms |
160404 KB |
Output is correct |
15 |
Correct |
507 ms |
160444 KB |
Output is correct |
16 |
Correct |
519 ms |
160212 KB |
Output is correct |
17 |
Correct |
514 ms |
160120 KB |
Output is correct |
18 |
Correct |
515 ms |
160120 KB |
Output is correct |
19 |
Correct |
521 ms |
160248 KB |
Output is correct |
20 |
Correct |
519 ms |
160316 KB |
Output is correct |
21 |
Correct |
520 ms |
160372 KB |
Output is correct |
22 |
Correct |
519 ms |
160300 KB |
Output is correct |
23 |
Correct |
520 ms |
160160 KB |
Output is correct |
24 |
Correct |
518 ms |
160244 KB |
Output is correct |
25 |
Correct |
514 ms |
160284 KB |
Output is correct |
26 |
Correct |
520 ms |
160380 KB |
Output is correct |
27 |
Runtime error |
756 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
538 ms |
160316 KB |
Output is correct |
2 |
Correct |
536 ms |
160248 KB |
Output is correct |
3 |
Correct |
535 ms |
160336 KB |
Output is correct |
4 |
Correct |
524 ms |
160252 KB |
Output is correct |
5 |
Correct |
534 ms |
160368 KB |
Output is correct |
6 |
Correct |
535 ms |
160288 KB |
Output is correct |
7 |
Correct |
532 ms |
160248 KB |
Output is correct |
8 |
Correct |
531 ms |
160264 KB |
Output is correct |
9 |
Correct |
535 ms |
160316 KB |
Output is correct |
10 |
Correct |
535 ms |
160248 KB |
Output is correct |
11 |
Correct |
527 ms |
160252 KB |
Output is correct |
12 |
Correct |
529 ms |
160248 KB |
Output is correct |
13 |
Correct |
529 ms |
160252 KB |
Output is correct |
14 |
Runtime error |
742 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |