QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#606758 | #8936. Team Arrangement | ucup-team902# | WA | 1ms | 4108kb | C++17 | 1.0kb | 2024-10-03 12:02:16 | 2024-10-03 12:02:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=60;
const int inf=1<<30;
int n;
vector<int> r[N+5];
int w[N+5];
int val[N+5];
int ans;
bool work(){
priority_queue<int,vector<int>,greater<int>> q;
for(int i=1;i<=n;i++){
for(auto j:r[i]) q.push(j);
int c=val[i];
while(!q.empty()&&c){
int t=q.top(); q.pop();
if(t<i) return 0;
c--;
}
if(c>0) return 0;
}
return 1;
}
void dfs(int x,int s,int ws){
if(s==0){
if(work()) ans=max(ans,ws);
return;
}
if(x>s) return;
for(int j=0;j*x<=s;j++){
val[x]=j;
dfs(x+1,s-j*x,ws+w[x]*j);
val[x]=0;
}
}
int main(){
scanf("%d",&n);
for(int i=1,l,rr;i<=n;i++){
scanf("%d %d",&l,&rr);
r[l].push_back(rr);
}
for(int i=1;i<=n;i++)
scanf("%d",&w[i]);
ans=-inf;
dfs(1,n,0);
if(ans==-inf){
puts("impossible");
}
else{
printf("%d\n",ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 1ms
memory: 4108kb
input:
3 1 3 3 3 2 3 1 1 100
output:
100
result:
ok single line: '100'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
3 2 3 1 2 2 2 -100 -200 100000
output:
-300
result:
ok single line: '-300'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
9 1 4 2 5 3 4 1 5 1 1 2 5 3 5 1 3 1 1 1 1 1 1 1 1 1 1 1
output:
7
result:
wrong answer 1st lines differ - expected: '6', found: '7'