QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#540032 | #8936. Team Arrangement | ucup-team3510# | WA | 0ms | 3696kb | C++14 | 1.1kb | 2024-08-31 16:17:11 | 2024-08-31 16:17:15 |
Judging History
answer
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int n,l[65],r[65],a[65],s[65],ans=-1e9;
vector<int> e[65];
inline bool judge(int m)
{
static int box[65];
memset(box,0,sizeof(box));
for(int i=1,j=1;i<=m;i++)
{
while(j<=s[i])
{
for(int k=0;k<e[j].size();k++)
{
box[e[j][k]]++;
}
j++;
}
int sum=s[i];
for(int k=s[i];k<=n;k++)
{
if(box[k]>=sum)
{
box[k]-=sum,sum=0;
break;
}
sum-=box[k];
}
if(sum)
{
return 0;
}
}
return 1;
}
void dfs(int now,int sum,int val,int last)
{
if(sum==n)
{
if(val>ans&&judge(now-1))
{
ans=val;
}
return;
}
for(int i=last;sum+i<=n;i++)
{
s[now]=i;
dfs(now+1,sum+i,val+a[i],i);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>l[i]>>r[i];
e[l[i]].emplace_back(r[i]);
}
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
dfs(1,0,0,1);
if(ans>-1e9)
{
cout<<ans<<endl;
return 0;
}
cout<<"impossible"<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 3696kb
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: 3556kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3552kb
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: 3624kb
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: 0
Accepted
time: 0ms
memory: 3636kb
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:
-16558567
result:
ok single line: '-16558567'
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
14 1 2 1 4 2 3 3 5 4 5 2 5 2 4 2 4 1 2 3 4 1 5 2 4 1 1 4 5 -13763 -7354207 1096407 -9063321 -4824546 -6275546 1258145 -5272834 -8631107 3581157 2320771 -7714508 8446625 -6816167
output:
4358102
result:
wrong answer 1st lines differ - expected: '-2673021', found: '4358102'