Submission #766285

# Submission time Handle Problem Language Result Execution time Memory
766285 2023-06-25T12:49:29 Z ivopav Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 304 KB
#include <bits/stdc++.h>
using namespace std;

int dp(int ind,int kol,int zbr,const vector<int>& lis,vector<vector<int>>& mem,int sad,int a,int b){
    if (ind==lis.size()){
        if (kol<a){
            return numeric_limits<int>::max()/2;
        }
        if ((zbr|sad)>sad){
            return numeric_limits<int>::max()/2;
        }
        return zbr;
    }
    if (mem[ind][kol]!=-1){
        return mem[ind][kol]+zbr;
    }
    int najm=dp(ind+1,kol,zbr+lis[ind],lis,mem,sad,a,b);
    if (kol!=b && (zbr|sad)<=sad && zbr!=0){
        najm=min(najm,dp(ind+1,kol+1,lis[ind],lis,mem,sad,a,b));
    }
    mem[ind][kol]=najm-zbr;
    return najm;
}

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

Compilation message

sculpture.cpp: In function 'int dp(int, int, int, const std::vector<int>&, std::vector<std::vector<int> >&, int, int, int)':
sculpture.cpp:5:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |     if (ind==lis.size()){
      |         ~~~^~~~~~~~~~~~
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Incorrect 1 ms 300 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 300 KB Output isn't correct
8 Halted 0 ms 0 KB -