답안 #297489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
297489 2020-09-11T15:24:29 Z AaronNaidu Bali Sculptures (APIO15_sculpture) C++14
9 / 100
1000 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, a, b;
ll y[2001];
ll prefSums[2001];
ll minAns = 1000000000000;

void makeSubset(int x, vector<int> v) {
    if (x == n-1)
    {
        v.push_back(n-1);
        if (a <= v.size() and v.size() <= b)
        {
            ll thisAns = prefSums[v[0]];
            ll thisSum = 0;
            for (int i = 1; i < v.size(); i++)
            {
                thisSum = prefSums[v[i]] - prefSums[v[i-1]];

                thisAns |= thisSum;
            }
            minAns = min(minAns, thisAns);
        }
        return;
    }
    v.push_back(x);
    makeSubset(x+1, v);
    v.pop_back();
    makeSubset(x+1, v);
}

int main() {
    cin >> n >> a >> b;
    cin >> y[0];
    prefSums[0] = y[0];
    for (int i = 1; i < n; i++)
    {
        cin >> y[i];
        prefSums[i] = prefSums[i-1] + y[i];
    }
    makeSubset(0, {});
    cout << minAns << "\n";
}

Compilation message

sculpture.cpp: In function 'void makeSubset(int, std::vector<int>)':
sculpture.cpp:14:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         if (a <= v.size() and v.size() <= b)
      |             ~~^~~~~~~~~~~
sculpture.cpp:14:40: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   14 |         if (a <= v.size() and v.size() <= b)
      |                               ~~~~~~~~~^~~~
sculpture.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |             for (int i = 1; i < v.size(); i++)
      |                             ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 13 ms 256 KB Output is correct
8 Correct 104 ms 416 KB Output is correct
9 Correct 104 ms 256 KB Output is correct
10 Correct 103 ms 384 KB Output is correct
11 Correct 112 ms 256 KB Output is correct
12 Correct 99 ms 384 KB Output is correct
13 Correct 107 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Correct 99 ms 376 KB Output is correct
22 Correct 103 ms 376 KB Output is correct
23 Correct 99 ms 376 KB Output is correct
24 Correct 103 ms 384 KB Output is correct
25 Correct 100 ms 504 KB Output is correct
26 Correct 106 ms 376 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 54 ms 256 KB Output is correct
31 Correct 98 ms 376 KB Output is correct
32 Correct 102 ms 376 KB Output is correct
33 Correct 106 ms 376 KB Output is correct
34 Correct 109 ms 256 KB Output is correct
35 Correct 98 ms 376 KB Output is correct
36 Correct 108 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 13 ms 384 KB Output is correct
8 Correct 96 ms 376 KB Output is correct
9 Correct 101 ms 380 KB Output is correct
10 Correct 97 ms 376 KB Output is correct
11 Correct 97 ms 376 KB Output is correct
12 Correct 97 ms 376 KB Output is correct
13 Correct 113 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 15 ms 256 KB Output is correct
21 Correct 103 ms 256 KB Output is correct
22 Correct 105 ms 376 KB Output is correct
23 Correct 100 ms 504 KB Output is correct
24 Correct 97 ms 376 KB Output is correct
25 Correct 101 ms 376 KB Output is correct
26 Correct 107 ms 256 KB Output is correct
27 Correct 217 ms 256 KB Output is correct
28 Execution timed out 1049 ms 384 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 13 ms 256 KB Output is correct
8 Correct 129 ms 376 KB Output is correct
9 Correct 100 ms 376 KB Output is correct
10 Correct 114 ms 384 KB Output is correct
11 Correct 96 ms 256 KB Output is correct
12 Correct 110 ms 376 KB Output is correct
13 Correct 109 ms 376 KB Output is correct
14 Correct 217 ms 376 KB Output is correct
15 Execution timed out 1083 ms 256 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 13 ms 384 KB Output is correct
8 Correct 100 ms 376 KB Output is correct
9 Correct 104 ms 376 KB Output is correct
10 Correct 97 ms 376 KB Output is correct
11 Correct 101 ms 384 KB Output is correct
12 Correct 98 ms 376 KB Output is correct
13 Correct 123 ms 376 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 13 ms 256 KB Output is correct
21 Correct 103 ms 376 KB Output is correct
22 Correct 101 ms 256 KB Output is correct
23 Correct 104 ms 376 KB Output is correct
24 Correct 97 ms 376 KB Output is correct
25 Correct 111 ms 376 KB Output is correct
26 Correct 109 ms 384 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 54 ms 376 KB Output is correct
31 Correct 107 ms 376 KB Output is correct
32 Correct 101 ms 256 KB Output is correct
33 Correct 114 ms 376 KB Output is correct
34 Correct 106 ms 384 KB Output is correct
35 Correct 107 ms 376 KB Output is correct
36 Correct 107 ms 376 KB Output is correct
37 Correct 214 ms 376 KB Output is correct
38 Execution timed out 1062 ms 256 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 15 ms 256 KB Output is correct
8 Correct 101 ms 376 KB Output is correct
9 Correct 99 ms 384 KB Output is correct
10 Correct 100 ms 256 KB Output is correct
11 Correct 99 ms 376 KB Output is correct
12 Correct 97 ms 384 KB Output is correct
13 Correct 109 ms 504 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 51 ms 256 KB Output is correct
18 Correct 101 ms 376 KB Output is correct
19 Correct 97 ms 384 KB Output is correct
20 Correct 123 ms 376 KB Output is correct
21 Correct 105 ms 256 KB Output is correct
22 Correct 99 ms 256 KB Output is correct
23 Correct 106 ms 380 KB Output is correct
24 Correct 217 ms 256 KB Output is correct
25 Execution timed out 1052 ms 256 KB Time limit exceeded
26 Halted 0 ms 0 KB -