# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
707983 | 2023-03-10T16:34:36 Z | ssense | Bali Sculptures (APIO15_sculpture) | C++14 | 1000 ms | 27772 KB |
#include <bits/stdc++.h> #define startt ios_base::sync_with_stdio(false);cin.tie(0); typedef long long ll; using namespace std; #define vint vector<int> #define all(v) v.begin(), v.end() #define MOD 1000000007 #define MOD2 998244353 #define MX 1000000000 #define MXL 1000000000000000000 #define PI (ld)2*acos(0.0) #define pb push_back #define sc second #define fr first #define endl '\n' #define ld long double #define NO cout << "NO" << endl #define YES cout << "YES" << endl int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);} int factorial(int n, int mod) {if (n > 1)return (n * factorial(n - 1, mod)) % mod; else return 1;} int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}struct prefix_sum{vint pref;void build(vint a){pref.pb(0);for(int i = 0; i < a.size(); i++){pref.pb(pref.back()+a[i]);}}int get(int l, int r){return pref[r]-pref[l-1];}};//mesanu int dp[105][2049][105]; void solve() { int n; cin >> n; int a, b; cin >> a >> b; vint y = read(n); prefix_sum pref; pref.build(y); dp[0][0][0] = 1; for(int i = 1; i <= n; i++) { //se termina la i grupul for(int j = 0; j < i; j++) { for(int orr = 0; orr <= 1<<(32-__builtin_clz(pref.get(1, j))); orr++) { for(int grup = 0; grup < b; grup++) { dp[i][(orr|pref.get(j+1, i))][grup+1]|=dp[j][orr][grup]; } } } } int ans = MX; for(int orr = 2048; orr >= 0; orr--) { for(int grup = a; grup <= b; grup++) { ans = min(ans, (dp[n][orr][grup] ? orr : MX)); } } cout << ans << endl; } int32_t main(){ startt int t = 1; //cin >> t; while (t--) { solve(); } } /* 6 1 3 8 1 2 1 5 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 2 ms | 1492 KB | Output is correct |
10 | Correct | 2 ms | 1748 KB | Output is correct |
11 | Correct | 1 ms | 1748 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 2 ms | 852 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 468 KB | Output is correct |
19 | Correct | 1 ms | 680 KB | Output is correct |
20 | Correct | 1 ms | 980 KB | Output is correct |
21 | Correct | 1 ms | 1108 KB | Output is correct |
22 | Correct | 2 ms | 1620 KB | Output is correct |
23 | Correct | 2 ms | 1748 KB | Output is correct |
24 | Correct | 2 ms | 1748 KB | Output is correct |
25 | Correct | 1 ms | 724 KB | Output is correct |
26 | Correct | 2 ms | 852 KB | Output is correct |
27 | Runtime error | 2 ms | 340 KB | Execution killed with signal 11 |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 1 ms | 1492 KB | Output is correct |
10 | Correct | 2 ms | 1748 KB | Output is correct |
11 | Correct | 1 ms | 1748 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 468 KB | Output is correct |
19 | Correct | 2 ms | 724 KB | Output is correct |
20 | Correct | 1 ms | 980 KB | Output is correct |
21 | Correct | 1 ms | 1108 KB | Output is correct |
22 | Correct | 3 ms | 1620 KB | Output is correct |
23 | Correct | 2 ms | 1748 KB | Output is correct |
24 | Correct | 1 ms | 1748 KB | Output is correct |
25 | Correct | 1 ms | 724 KB | Output is correct |
26 | Correct | 2 ms | 852 KB | Output is correct |
27 | Correct | 2 ms | 1108 KB | Output is correct |
28 | Correct | 2 ms | 1492 KB | Output is correct |
29 | Correct | 4 ms | 3284 KB | Output is correct |
30 | Correct | 12 ms | 3284 KB | Output is correct |
31 | Correct | 40 ms | 8108 KB | Output is correct |
32 | Correct | 47 ms | 8864 KB | Output is correct |
33 | Correct | 7 ms | 8788 KB | Output is correct |
34 | Correct | 13 ms | 4248 KB | Output is correct |
35 | Correct | 18 ms | 5204 KB | Output is correct |
36 | Correct | 14 ms | 4948 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 2 ms | 1492 KB | Output is correct |
10 | Correct | 2 ms | 1748 KB | Output is correct |
11 | Correct | 2 ms | 1748 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 2 ms | 852 KB | Output is correct |
14 | Correct | 2 ms | 1108 KB | Output is correct |
15 | Correct | 2 ms | 1492 KB | Output is correct |
16 | Correct | 5 ms | 3284 KB | Output is correct |
17 | Correct | 12 ms | 3352 KB | Output is correct |
18 | Correct | 31 ms | 8152 KB | Output is correct |
19 | Correct | 42 ms | 8808 KB | Output is correct |
20 | Correct | 8 ms | 8788 KB | Output is correct |
21 | Correct | 19 ms | 4232 KB | Output is correct |
22 | Correct | 13 ms | 5252 KB | Output is correct |
23 | Correct | 14 ms | 4948 KB | Output is correct |
24 | Correct | 42 ms | 8168 KB | Output is correct |
25 | Correct | 48 ms | 13772 KB | Output is correct |
26 | Correct | 173 ms | 20688 KB | Output is correct |
27 | Correct | 612 ms | 27772 KB | Output is correct |
28 | Execution timed out | 1082 ms | 27164 KB | Time limit exceeded |
29 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 2 ms | 1492 KB | Output is correct |
10 | Correct | 2 ms | 1748 KB | Output is correct |
11 | Correct | 2 ms | 1748 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 2 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 468 KB | Output is correct |
19 | Correct | 1 ms | 724 KB | Output is correct |
20 | Correct | 1 ms | 980 KB | Output is correct |
21 | Correct | 2 ms | 1108 KB | Output is correct |
22 | Correct | 2 ms | 1632 KB | Output is correct |
23 | Correct | 2 ms | 1748 KB | Output is correct |
24 | Correct | 2 ms | 1748 KB | Output is correct |
25 | Correct | 1 ms | 724 KB | Output is correct |
26 | Correct | 1 ms | 852 KB | Output is correct |
27 | Runtime error | 2 ms | 392 KB | Execution killed with signal 11 |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 2 ms | 1492 KB | Output is correct |
10 | Correct | 2 ms | 1748 KB | Output is correct |
11 | Correct | 2 ms | 1748 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 2 ms | 852 KB | Output is correct |
14 | Runtime error | 2 ms | 468 KB | Execution killed with signal 11 |
15 | Halted | 0 ms | 0 KB | - |