답안 #766751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766751 2023-06-26T06:25:28 Z ivopav Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 16636 KB
#include <bits/stdc++.h>
using namespace std;

bool dp(long long int ind,long long int kol,const vector<long long int>& lis,vector<vector<int>>& mem,long long int sad,long long int a,long long int b){
   // cout << sad << " " << ind << " " << kol << " " << zbr << "\n";
    if (ind==lis.size()){
        if (kol<a){
            return false;
        }
        return true;;
    }
    if (mem[ind][kol]!=-1){
        return mem[ind][kol];
    }
    if (kol==b){
        return false;
    }
    //long long int najm=dp(ind+1ll,kol,zbr+lis[ind],lis,mem,sad,a,b);
    long long int zbr=0ll;
    bool najm=false;
    for (long long int i=ind;i<lis.size();i++){
        zbr+=lis[i];
        if ((zbr|sad)==sad){
            najm=najm||dp(i+1ll,kol+1ll,lis,mem,sad,a,b);
        }
    }
    mem[ind][kol]=najm;
    return najm;
}

int main(){
    
    long long int n;
    long long int a;
    long long int b;
    cin >> n >> a >> b; 
    vector<long long int> lis={};
    for (long long int i=0ll;i<n;i++){
        long long int unos;
        cin >> unos;
        lis.push_back(unos);                 
    }
    long long int sad=numeric_limits<long long int>::max();
    long long int sadznam=1ll;
    for (long long int i=0ll;i<62ll;i++){
        sadznam*=2ll;
    }
    while (sadznam>0){
        vector <vector<int>> mem=vector<vector<int>>(n+5ll,vector<int>(b+5ll,-1));
        if (dp(0ll,0ll,lis,mem,sad-sadznam,a,b)){
            sad-=sadznam;
        }
        sadznam/=2ll;
    }
    cout << sad << "\n";
}

Compilation message

sculpture.cpp: In function 'bool dp(long long int, long long int, const std::vector<long long int>&, std::vector<std::vector<int> >&, long long int, long long int, long long int)':
sculpture.cpp:6:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     if (ind==lis.size()){
      |         ~~~^~~~~~~~~~~~
sculpture.cpp:21:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (long long int i=ind;i<lis.size();i++){
      |                              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 224 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 284 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 300 KB Output is correct
44 Correct 1 ms 252 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 296 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 300 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 296 KB Output is correct
63 Correct 2 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 1 ms 292 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 296 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 304 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 300 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 2 ms 296 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 216 KB Output is correct
3 Correct 0 ms 216 KB Output is correct
4 Correct 0 ms 216 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 0 ms 216 KB Output is correct
9 Correct 0 ms 216 KB Output is correct
10 Correct 0 ms 220 KB Output is correct
11 Correct 1 ms 224 KB Output is correct
12 Correct 0 ms 224 KB Output is correct
13 Correct 0 ms 224 KB Output is correct
14 Correct 0 ms 224 KB Output is correct
15 Correct 0 ms 224 KB Output is correct
16 Correct 0 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 0 ms 224 KB Output is correct
20 Correct 0 ms 224 KB Output is correct
21 Correct 0 ms 224 KB Output is correct
22 Correct 0 ms 224 KB Output is correct
23 Correct 0 ms 224 KB Output is correct
24 Correct 0 ms 224 KB Output is correct
25 Correct 1 ms 224 KB Output is correct
26 Correct 0 ms 224 KB Output is correct
27 Correct 0 ms 224 KB Output is correct
28 Correct 1 ms 224 KB Output is correct
29 Correct 1 ms 304 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 300 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 296 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 300 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 2 ms 340 KB Output is correct
51 Correct 1 ms 300 KB Output is correct
52 Correct 91 ms 576 KB Output is correct
53 Correct 48 ms 2868 KB Output is correct
54 Correct 168 ms 340 KB Output is correct
55 Correct 162 ms 684 KB Output is correct
56 Correct 772 ms 8528 KB Output is correct
57 Correct 384 ms 16532 KB Output is correct
58 Correct 386 ms 16636 KB Output is correct
59 Correct 394 ms 16528 KB Output is correct
60 Correct 5 ms 340 KB Output is correct
61 Correct 2 ms 212 KB Output is correct
62 Correct 43 ms 2712 KB Output is correct
63 Correct 182 ms 420 KB Output is correct
64 Correct 78 ms 4648 KB Output is correct
65 Correct 356 ms 2732 KB Output is correct
66 Correct 283 ms 12860 KB Output is correct
67 Correct 5 ms 340 KB Output is correct
68 Execution timed out 1067 ms 956 KB Time limit exceeded
69 Halted 0 ms 0 KB -