QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#696109 | #8936. Team Arrangement | 2018haha# | WA | 0ms | 3620kb | C++17 | 1.6kb | 2024-10-31 21:33:45 | 2024-10-31 21:33:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=100;
int n;
int w[N];
pair<int,int> a[N];
int ans[N],rest;
ll Ans;
void Dfs(int d)
{
if(d==0)
{
if(rest) return;
priority_queue<int> group,people;
int p=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=ans[i]*i;j++)
group.push(i);
while(p+1<=n && a[p+1].first<=i)
{
people.push(a[p+1].second);
p++;
}
while(group.size() && people.size())
{
if(people.top()>=group.top()) people.pop(),group.pop();
else break;
}
while(group.size()) group.pop();
}
if(group.size()) return;
if(people.size()) return;
for(int i=1;i<=n;i++)
cerr<<ans[i]<<" ";
ll tmp=0;
for(int i=1;i<=n;i++)
tmp+=ans[i]*w[i];
cerr<<"|"<<tmp<<"\n";
Ans=max(Ans,tmp);
// for(int i=1;i<=n;i++)
// cout<<ans[i]<<" ";
// cout<<"\n";
return;
}
Dfs(d-1);
int tmp=rest;
while(rest>=d)
{
ans[d]++;
rest-=d;
Dfs(d-1);
}
ans[d]=0;
rest=tmp;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i].first>>a[i].second;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
cin>>w[i];
rest=n;
Ans=-1e18;
Dfs(n);
if(Ans==(ll)-1e18) cout<<"impossible\n";
else cout<<Ans<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3 1 3 3 3 2 3 1 1 100
output:
100
result:
ok single line: '100'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
3 2 3 1 2 2 2 -100 -200 100000
output:
-300
result:
ok single line: '-300'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3616kb
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:
6
result:
ok single line: '6'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
14 3 3 1 2 2 3 2 3 2 3 1 1 2 3 1 3 3 3 1 3 1 3 1 2 2 3 1 3 -9807452 -9610069 4156341 2862447 6969109 -7245265 -2653530 -5655094 6467527 -6872459 3971784 7312155 9766298 -2719573
output:
-83715961
result:
wrong answer 1st lines differ - expected: '-16558567', found: '-83715961'