QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203023 | #2481. Pickpockets | Vengeful_Spirit# | WA | 1ms | 4144kb | C++14 | 1.5kb | 2023-10-06 14:44:08 | 2023-10-06 14:44:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int a[1<<16],b[1<<16];
int f[1<<16],g[1<<16];
int main(){
int n,m;
scanf("%d%d",&n,&m);
int cur=0;
vector<int>q;
vector<int>t;
for(int day=1;day<=n;day++){
int x;
scanf("%d",&x);
if(cur<x){
for(int i=cur+1;i<=x;i++)q.push_back(day);
}
else if(cur>x){
while(q.size()>x){
int y=q.back();
q.pop_back();
t.push_back(day-y);
if(q.size()>m){
puts("0");
return 0;
}
}
}
cur=x;
}
while(!q.empty()){
t.push_back(n-q.back()+1);
q.pop_back();
}
for(int i=0;i<m;i++){
scanf("%d%d",&a[1<<i],&b[1<<i]);
}
for(int i=0;i<(1<<m);i++){
for(int j=0;j<m;j++){
if(i>>j&1&&i!=(1<<j))a[i]+=a[1<<j],b[i]+=b[1<<j];
}
}
int ans=0;
for(int i=0;i<t.size();i++){
memcpy(g,f,sizeof(f));
// cout<<i<<' '<<t[i]<<endl;
for(int u=1;u<(1<<m);u++){
for(int s=u; s>0; s=(s-1)&u){
// cout<<s<<" "<<a[s]<<' '<<b[s]<<endl;
if(a[s]==t[i]){
f[u]=max(f[u],g[u^s]+b[s]);
}
}
if(i==t.size()-1)ans=max(ans,f[u]);
// cout<<" "<<u<<" "<<f[u]<<endl;
}
}
printf("%d\n",ans);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4080kb
input:
2 2 1 2 1 5 2 5
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 1ms
memory: 4048kb
input:
2 2 1 2 2 5 1 5
output:
10
result:
ok single line: '10'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4080kb
input:
3 4 2 1 2 3 2 1 1 1 2 1 3
output:
7
result:
ok single line: '7'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4088kb
input:
1 5 2 1 2 1 5 1 3 1 5 1 3
output:
10
result:
ok single line: '10'
Test #5:
score: 0
Accepted
time: 0ms
memory: 4144kb
input:
1 5 1 1 2 1 1 1 2 1 5 1 2
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
1 7 0 1 5 1 5 1 5 1 2 1 5 1 3 1 6
output:
0
result:
ok single line: '0'
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 4088kb
input:
3 6 2 1 1 2 1 3 5 2 3 3 3 2 4 3 3
output:
5
result:
wrong answer 1st lines differ - expected: '0', found: '5'