QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649156 | #8936. Team Arrangement | argtarg | WA | 0ms | 3860kb | C++20 | 1.7kb | 2024-10-17 21:53:44 | 2024-10-17 21:53:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl '\n'
#define pii pair<int, int>
void solve();
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
// cin >> T;
while (T--)solve();
return 0;
}
void solve(){
int n;
cin>>n;
vector<pii>a(n+1);
for(int i=1;i<=n;i++){
cin>>a[i].first>>a[i].second;
}
sort(a.begin()+1,a.end());
long long ans=-1e10;
vector<int>num(n+1),w(n+1);
for(int i=1;i<=n;i++){
cin>>w[i];
}
int cnt=0,ccnt=0;
auto dfs=[&](auto dfs,int re,int x)->void{
cnt++;
if(re==0){
ccnt++;
long long tmp=0;
int ok=1,l=1;
long long x=0;
for(int i=1;i<=n;i++){
if(ok==0)break;
// cout<<num[i]<<' ';
tmp+=1ll*num[i]*w[i];
while(l<=n&&a[l].first<=i){
x+=(1ll<<a[l].second*1ll);
l++;
}
for(int j=0;j<num[i]*i;j++) {
if((x&-x)>=(1ll<<i*1ll)){
x-=(x&-x);
}
else {
ok=0;
break;
}
}
}
if(ok==1)ans=max(ans,tmp);
return;
}
if(x==0)return;
for(int j=min(re,x);j>=1;--j){
num[j]++;
dfs(dfs,re-j,min(re-j,j));
num[j]--;
}
};
dfs(dfs,n,n);
// cout<<cnt<<endl;
// cout<<ccnt<<endl;
cout<<(ans==-1e10 ? "impossible":to_string(ans))<<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
3 1 3 3 3 2 3 1 1 100
output:
impossible
result:
wrong answer 1st lines differ - expected: '100', found: 'impossible'