#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[2002][101][101];
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[i][j][n]=-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 |
125 ms |
160248 KB |
Output is correct |
2 |
Correct |
129 ms |
160124 KB |
Output is correct |
3 |
Correct |
129 ms |
160120 KB |
Output is correct |
4 |
Correct |
129 ms |
160120 KB |
Output is correct |
5 |
Correct |
129 ms |
160184 KB |
Output is correct |
6 |
Correct |
130 ms |
160228 KB |
Output is correct |
7 |
Correct |
130 ms |
160096 KB |
Output is correct |
8 |
Correct |
129 ms |
160168 KB |
Output is correct |
9 |
Correct |
129 ms |
160180 KB |
Output is correct |
10 |
Correct |
130 ms |
160248 KB |
Output is correct |
11 |
Correct |
131 ms |
160308 KB |
Output is correct |
12 |
Correct |
130 ms |
160120 KB |
Output is correct |
13 |
Correct |
130 ms |
160216 KB |
Output is correct |
14 |
Correct |
130 ms |
160220 KB |
Output is correct |
15 |
Correct |
130 ms |
160248 KB |
Output is correct |
16 |
Correct |
129 ms |
160188 KB |
Output is correct |
17 |
Correct |
129 ms |
160120 KB |
Output is correct |
18 |
Correct |
130 ms |
160204 KB |
Output is correct |
19 |
Correct |
129 ms |
160248 KB |
Output is correct |
20 |
Correct |
130 ms |
160120 KB |
Output is correct |
21 |
Correct |
129 ms |
160120 KB |
Output is correct |
22 |
Correct |
129 ms |
160224 KB |
Output is correct |
23 |
Correct |
129 ms |
160248 KB |
Output is correct |
24 |
Correct |
130 ms |
160248 KB |
Output is correct |
25 |
Correct |
129 ms |
160212 KB |
Output is correct |
26 |
Correct |
130 ms |
160176 KB |
Output is correct |
27 |
Runtime error |
344 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 |
131 ms |
160120 KB |
Output is correct |
2 |
Correct |
131 ms |
160220 KB |
Output is correct |
3 |
Correct |
131 ms |
160100 KB |
Output is correct |
4 |
Correct |
148 ms |
160196 KB |
Output is correct |
5 |
Correct |
133 ms |
160276 KB |
Output is correct |
6 |
Correct |
125 ms |
160040 KB |
Output is correct |
7 |
Correct |
126 ms |
160224 KB |
Output is correct |
8 |
Correct |
169 ms |
160220 KB |
Output is correct |
9 |
Correct |
133 ms |
160220 KB |
Output is correct |
10 |
Correct |
132 ms |
160236 KB |
Output is correct |
11 |
Correct |
133 ms |
160248 KB |
Output is correct |
12 |
Correct |
130 ms |
160328 KB |
Output is correct |
13 |
Correct |
131 ms |
160248 KB |
Output is correct |
14 |
Correct |
130 ms |
160264 KB |
Output is correct |
15 |
Correct |
135 ms |
160120 KB |
Output is correct |
16 |
Correct |
130 ms |
160248 KB |
Output is correct |
17 |
Correct |
130 ms |
160120 KB |
Output is correct |
18 |
Correct |
130 ms |
160288 KB |
Output is correct |
19 |
Correct |
132 ms |
160248 KB |
Output is correct |
20 |
Correct |
130 ms |
160248 KB |
Output is correct |
21 |
Correct |
129 ms |
160220 KB |
Output is correct |
22 |
Correct |
133 ms |
160248 KB |
Output is correct |
23 |
Correct |
130 ms |
160240 KB |
Output is correct |
24 |
Correct |
130 ms |
160248 KB |
Output is correct |
25 |
Correct |
148 ms |
160188 KB |
Output is correct |
26 |
Correct |
152 ms |
160292 KB |
Output is correct |
27 |
Correct |
158 ms |
160096 KB |
Output is correct |
28 |
Correct |
146 ms |
160092 KB |
Output is correct |
29 |
Correct |
152 ms |
160172 KB |
Output is correct |
30 |
Correct |
133 ms |
160196 KB |
Output is correct |
31 |
Correct |
142 ms |
160212 KB |
Output is correct |
32 |
Correct |
132 ms |
160184 KB |
Output is correct |
33 |
Correct |
132 ms |
160120 KB |
Output is correct |
34 |
Correct |
133 ms |
160168 KB |
Output is correct |
35 |
Correct |
154 ms |
160120 KB |
Output is correct |
36 |
Correct |
134 ms |
160136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
131 ms |
160124 KB |
Output is correct |
2 |
Correct |
131 ms |
160132 KB |
Output is correct |
3 |
Correct |
131 ms |
160124 KB |
Output is correct |
4 |
Correct |
131 ms |
160116 KB |
Output is correct |
5 |
Correct |
130 ms |
160248 KB |
Output is correct |
6 |
Correct |
130 ms |
160204 KB |
Output is correct |
7 |
Correct |
131 ms |
160144 KB |
Output is correct |
8 |
Correct |
131 ms |
160248 KB |
Output is correct |
9 |
Correct |
131 ms |
160204 KB |
Output is correct |
10 |
Correct |
125 ms |
160248 KB |
Output is correct |
11 |
Correct |
131 ms |
160336 KB |
Output is correct |
12 |
Correct |
144 ms |
160320 KB |
Output is correct |
13 |
Correct |
151 ms |
160120 KB |
Output is correct |
14 |
Correct |
146 ms |
160248 KB |
Output is correct |
15 |
Correct |
130 ms |
160184 KB |
Output is correct |
16 |
Correct |
130 ms |
160144 KB |
Output is correct |
17 |
Correct |
131 ms |
160152 KB |
Output is correct |
18 |
Correct |
134 ms |
160176 KB |
Output is correct |
19 |
Correct |
127 ms |
160120 KB |
Output is correct |
20 |
Correct |
140 ms |
160164 KB |
Output is correct |
21 |
Correct |
134 ms |
160220 KB |
Output is correct |
22 |
Correct |
136 ms |
160220 KB |
Output is correct |
23 |
Correct |
136 ms |
160312 KB |
Output is correct |
24 |
Correct |
134 ms |
160300 KB |
Output is correct |
25 |
Incorrect |
139 ms |
160220 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
129 ms |
160220 KB |
Output is correct |
2 |
Correct |
131 ms |
160196 KB |
Output is correct |
3 |
Correct |
129 ms |
160248 KB |
Output is correct |
4 |
Correct |
130 ms |
160120 KB |
Output is correct |
5 |
Correct |
130 ms |
160184 KB |
Output is correct |
6 |
Correct |
133 ms |
160116 KB |
Output is correct |
7 |
Correct |
137 ms |
160168 KB |
Output is correct |
8 |
Correct |
136 ms |
160120 KB |
Output is correct |
9 |
Correct |
129 ms |
160248 KB |
Output is correct |
10 |
Correct |
132 ms |
160412 KB |
Output is correct |
11 |
Correct |
131 ms |
160252 KB |
Output is correct |
12 |
Correct |
130 ms |
160120 KB |
Output is correct |
13 |
Correct |
129 ms |
160164 KB |
Output is correct |
14 |
Correct |
130 ms |
160120 KB |
Output is correct |
15 |
Correct |
130 ms |
160248 KB |
Output is correct |
16 |
Correct |
130 ms |
160220 KB |
Output is correct |
17 |
Correct |
130 ms |
160308 KB |
Output is correct |
18 |
Correct |
131 ms |
160192 KB |
Output is correct |
19 |
Correct |
131 ms |
160120 KB |
Output is correct |
20 |
Correct |
131 ms |
160120 KB |
Output is correct |
21 |
Correct |
130 ms |
160100 KB |
Output is correct |
22 |
Correct |
131 ms |
160184 KB |
Output is correct |
23 |
Correct |
130 ms |
160248 KB |
Output is correct |
24 |
Correct |
125 ms |
160204 KB |
Output is correct |
25 |
Correct |
131 ms |
160248 KB |
Output is correct |
26 |
Correct |
130 ms |
160248 KB |
Output is correct |
27 |
Runtime error |
337 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 |
131 ms |
160220 KB |
Output is correct |
2 |
Correct |
133 ms |
160256 KB |
Output is correct |
3 |
Correct |
132 ms |
160144 KB |
Output is correct |
4 |
Correct |
130 ms |
160248 KB |
Output is correct |
5 |
Correct |
130 ms |
160160 KB |
Output is correct |
6 |
Correct |
146 ms |
160248 KB |
Output is correct |
7 |
Correct |
131 ms |
160248 KB |
Output is correct |
8 |
Correct |
131 ms |
160204 KB |
Output is correct |
9 |
Correct |
129 ms |
160128 KB |
Output is correct |
10 |
Correct |
131 ms |
160168 KB |
Output is correct |
11 |
Correct |
132 ms |
160104 KB |
Output is correct |
12 |
Correct |
132 ms |
160120 KB |
Output is correct |
13 |
Correct |
130 ms |
160220 KB |
Output is correct |
14 |
Runtime error |
389 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |