QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#820751 | #8936. Team Arrangement | kakakaa0# | RE | 1ms | 3844kb | C++20 | 1.6kb | 2024-12-19 00:32:34 | 2024-12-19 00:32:35 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int maxn=2e5+10;
int ans=-inf;
int n;
struct node{
int l,r,id;
bool operator <(const node &other) const
{
return r>other.r;
}
}a[66];
vector<node> b[66];
int w[66],c[66];
int su=0;
bool check(int cnt)
{
priority_queue<node> q;
int add=1;
for(int i=1;i<=cnt;i++)
{
while(add<=c[i])
{
for(auto p:b[add])
q.push(p);
add++;
}
if(q.top().r<c[i]) return 0;
if(q.size()<c[i]) return 0;
for(int j=1;j<=c[i];j++) q.pop();
}
return 1;
}
void dfs(int sum,int cnt)
{
if(sum==n)
{
// for(int i=1;i<=cnt;i++)
// cout<<c[i]<<" ";cout<<endl;
int res=0;
for(int i=1;i<=cnt;i++)
res+=w[c[i]];
if(res>ans)
{
if(check(cnt))
ans=res;
return;
}
}
for(int i=c[cnt];i+sum<=n;i++)
{
c[cnt+1]=i;
dfs(sum+i,cnt+1);
}
}
void kakakaa()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i].l>>a[i].r,a[i].id=i,b[a[i].l].pb(a[i]);
c[0]=1;
for(int i=1;i<=n;i++)
cin>>w[i];
dfs(0,0);
if(ans==-inf)
cout<<"impossible";
else
cout<<ans;
//cout<<endl<<su;
}
signed main()
{
ios::sync_with_stdio(false);//解除cin和cout的绑定,让它们可以独立缓冲
cin.tie(0);
cout.tie(0);
kakakaa();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3844kb
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: 3780kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
3 2 3 1 2 2 2 -100 -200 100000
output:
-300
result:
ok single line: '-300'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3620kb
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: 1ms
memory: 3580kb
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: 0
Accepted
time: 1ms
memory: 3556kb
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:
-2673021
result:
ok single line: '-2673021'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
14 2 3 4 4 1 7 3 6 3 4 1 1 1 4 4 7 3 7 1 7 2 3 6 6 1 1 3 6 2923142 1686477 640352 2848353 9202543 -4441381 4866381 -3610520 8124124 -1372894 1111310 -7538627 466143 9937961
output:
5939733
result:
ok single line: '5939733'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
14 1 7 1 2 8 8 1 1 7 8 6 9 7 8 1 4 6 9 3 3 1 1 3 7 5 8 4 8 -7139089 6365816 -9893288 5936146 -2803918 -4961415 1495365 -2564851 -2630365 -8608883 5813455 -4005459 -8844054 6703783
output:
impossible
result:
ok single line: 'impossible'
Test #10:
score: -100
Runtime Error
input:
14 6 13 3 7 2 13 6 8 4 5 12 13 3 10 4 11 2 14 3 4 5 13 10 14 10 14 3 12 -8599727 -1496394 855072 -7439122 -5170228 8009298 -250221 5841035 2949765 7166358 -3516548 -6851737 8173765 -917122