이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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";
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |