QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#667413 | #7159. Candy | Warinchai_s# | 0 | 4ms | 3836kb | C++14 | 757b | 2024-10-22 22:50:26 | 2024-10-22 22:50:34 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int ar[105];
int dp[105][105];
vector<pair<int,int>>v;
map<int,int>mp[105];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,f,t;cin>>n>>f>>t;
for(int i=0;i<n;i++){
cin>>ar[i];
}
int ans=LLONG_MAX;
for(int i=0;i<(1<<20);i++){
int x=__builtin_popcount(i);
if(x!=f)continue;
vector<int>v;
int sum=0;
for(int j=0;j<20;j++){
if((i>>j)&1)v.push_back(j),sum+=ar[j];
}
if(sum<t)continue;
int tans=0;
for(int j=0;j<f;j++){
tans+=v[j]-j;
}
ans=min(ans,tans);
}
cout<<(ans==LLONG_MAX?-1:ans);
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 4ms
memory: 3836kb
input:
1 1 7 7
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Wrong Answer
time: 3ms
memory: 3792kb
input:
1 1 8 7
output:
-1
result:
wrong answer 1st lines differ - expected: 'NO', found: '-1'
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 4ms
memory: 3776kb
input:
100 50 50 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
-1
result:
wrong answer 1st lines differ - expected: '1805', found: '-1'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%