QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#858896 | #8811. Heat Stroke | sichengzhou | 14 | 43ms | 4608kb | C++17 | 1.5kb | 2025-01-17 08:55:12 | 2025-01-17 08:55:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=8e3+8,M=18;
int n,a[N],m;
int f[1<<M];
void solve()
{
f[0]=0;
for(int i=1;i<(1<<n);i++)
{
f[i]=-1e9;
}
int x;
for(int i=1;i<=m;i++)
{
cin>>x;
// cout<<i<<endl;
for(int j=(1<<n)-1;j>=0;j--)
{
// if(f[j]>=0)cout<<j<<' '<<f[j]<<'\n';
int t=f[j];
f[j]=-1e9;
if((j>>x-1&3)==3)
{
f[j]=max(f[j],t+1);
}
if(j>>x-1&1)
{
f[j]=max(f[j],f[j^(1<<x-1)]);
}
if(j>>x&1)
{
f[j]=max(f[j],f[j^(1<<x)]);
}
}
}
int ans=0;
for(int i=0;i<(1<<n);i++)
{
ans=max(ans,f[i]);
}
cout<<ans<<'\n';
}
int main()
{
int x;
cin>>n;
bool fl=(n<=18);
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]>1)
{
fl=0;
}
}
cin>>m;
if(m>100)
{
fl=0;
}
if(fl)
{
solve();
return 0;
}
int ans=0;
for(int i=1;i<=m;i++)
{
cin>>x;
if(a[x+1]==0)
{
if(a[x]==0)
{
ans++;
}else{
a[x]--;
}
}else{
a[x+1]--;
}
}
cout<<ans<<'\n';
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
2 0 0 1 1
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #2:
score: 7
Accepted
Test #33:
score: 7
Accepted
time: 0ms
memory: 3584kb
input:
3 1 1 1 3 1 2 1
output:
1
result:
ok single line: '1'
Test #34:
score: 7
Accepted
time: 0ms
memory: 3456kb
input:
3 1 1 1 3 2 1 2
output:
1
result:
ok single line: '1'
Test #35:
score: 7
Accepted
time: 0ms
memory: 3584kb
input:
7 1 1 1 1 1 1 1 8 2 1 6 5 4 3 2 6
output:
3
result:
ok single line: '3'
Test #36:
score: 7
Accepted
time: 0ms
memory: 3584kb
input:
8 1 1 1 1 1 1 1 1 10 6 7 4 1 2 3 4 5 6 1
output:
4
result:
ok single line: '4'
Test #37:
score: 7
Accepted
time: 5ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13 13 17 13 9 15 4 12 11 12 7 5 15 1
output:
1
result:
ok single line: '1'
Test #38:
score: 7
Accepted
time: 6ms
memory: 4480kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 17 12 6 3 15 17 3 10 6 12 15 17 11 12 14
output:
3
result:
ok single line: '3'
Test #39:
score: 7
Accepted
time: 8ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 16 11 13 10 5 3 10 6 13 16 16 2 14 9 9 3
output:
4
result:
ok single line: '4'
Test #40:
score: 7
Accepted
time: 8ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 17 12 5 4 1 10 6 8 8 16 6 12 14 7 14 17 12 9
output:
4
result:
ok single line: '4'
Test #41:
score: 7
Accepted
time: 7ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 14 9 3 16 9 2 2 9 4 10 12 17 13 10 10 10 3 11
output:
7
result:
ok single line: '7'
Test #42:
score: 7
Accepted
time: 3ms
memory: 3968kb
input:
17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 15 9 6 3 13 9 13 16 7 5 8 1 1 9 9 15 16 1
output:
5
result:
ok single line: '5'
Test #43:
score: 7
Accepted
time: 2ms
memory: 3840kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 13 4 8 8 13 8 1 15 3 6 4 8 6 4 12 9 15 14
output:
5
result:
ok single line: '5'
Test #44:
score: 7
Accepted
time: 1ms
memory: 3712kb
input:
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 10 3 3 9 6 4 8 3 12 12 11 7 14 6 5 3 3
output:
6
result:
ok single line: '6'
Test #45:
score: 7
Accepted
time: 1ms
memory: 3584kb
input:
13 1 1 1 1 1 1 1 1 1 1 1 1 1 18 11 5 4 8 12 2 1 3 8 8 9 4 12 7 12 3 6 6
output:
7
result:
ok single line: '7'
Test #46:
score: 7
Accepted
time: 1ms
memory: 3584kb
input:
13 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11
output:
6
result:
ok single line: '6'
Test #47:
score: 7
Accepted
time: 8ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 5 7 11 13 17 2 4 8 10 14 16 1 5 7 11 13 17
output:
6
result:
ok single line: '6'
Test #48:
score: 7
Accepted
time: 0ms
memory: 3840kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 1 3 2 4 6 5 7 9 8 10 12 11 13 15 14
output:
5
result:
ok single line: '5'
Test #49:
score: 7
Accepted
time: 9ms
memory: 4480kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 1 2 4 5 4 7 8 8 11 10 10 14 13 14 17 17 16
output:
4
result:
ok single line: '4'
Test #50:
score: 7
Accepted
time: 2ms
memory: 3840kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 1 2 3 5 7 6 10 9 11 15 14 13
output:
1
result:
ok single line: '1'
Subtask #3:
score: 7
Accepted
Dependency #2:
100%
Accepted
Test #51:
score: 7
Accepted
time: 14ms
memory: 4480kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33 17 17 16 16 15 15 14 14 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1
output:
15
result:
ok single line: '15'
Test #52:
score: 7
Accepted
time: 8ms
memory: 4480kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20 16 6 17 10 14 2 12 6 12 16 9 16 1 1 8 16 15 1 5 6
output:
7
result:
ok single line: '7'
Test #53:
score: 7
Accepted
time: 11ms
memory: 4480kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 23 6 4 16 11 16 17 7 15 7 14 11 16 16 17 17 17 15 15 17 12 5 14 7
output:
11
result:
ok single line: '11'
Test #54:
score: 7
Accepted
time: 12ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 26 1 1 11 15 12 16 15 5 12 12 10 10 5 3 12 11 8 15 12 8 7 10 3 4 15 15
output:
11
result:
ok single line: '11'
Test #55:
score: 7
Accepted
time: 12ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 29 5 14 2 14 12 11 1 6 13 9 14 1 16 1 2 16 11 3 6 3 12 6 16 8 7 3 15 6 2
output:
14
result:
ok single line: '14'
Test #56:
score: 7
Accepted
time: 15ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 10 14 1 6 9 8 3 12 4 2 16 5 14 13 13 6 3 13 11 13 8 1 15 13 2 3 8 14 13 1 15 9
output:
18
result:
ok single line: '18'
Test #57:
score: 7
Accepted
time: 15ms
memory: 4480kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 35 3 9 4 14 11 1 2 4 6 14 12 7 8 14 11 15 7 10 2 9 2 3 11 3 2 7 3 5 16 3 3 11 9 17 12
output:
18
result:
ok single line: '18'
Test #58:
score: 7
Accepted
time: 17ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 38 7 14 9 15 8 7 6 6 10 15 10 16 6 13 11 8 15 11 12 16 2 5 13 10 3 4 14 4 12 8 8 17 11 5 9 5 12 16
output:
22
result:
ok single line: '22'
Test #59:
score: 7
Accepted
time: 18ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 41 15 16 17 13 2 16 3 2 10 3 16 11 9 13 1 3 16 2 3 17 10 12 8 2 9 2 8 17 4 8 10 1 1 13 7 6 14 13 2 9 1
output:
23
result:
ok single line: '23'
Test #60:
score: 7
Accepted
time: 43ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 100 3 1 15 2 12 2 12 16 8 6 9 14 15 16 17 13 8 8 9 14 17 8 17 2 3 14 3 10 17 7 11 1 17 1 17 9 14 6 1 2 6 9 7 11 7 6 15 9 4 14 10 3 17 15 14 4 8 16 10 11 15 9 15 17 15 7 12 7 7 4 9 4 14 14 6 14 10 7 15 7 14 4 1 5 17 4 3 4 8 4 1 7 9 1 7 9 12 9 17 2
output:
82
result:
ok single line: '82'
Test #61:
score: 7
Accepted
time: 5ms
memory: 4096kb
input:
17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 24 1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11 13 14 13 15 16 15
output:
8
result:
ok single line: '8'
Test #62:
score: 7
Accepted
time: 14ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 10 12 11 13 12 14 13 15 14 16 15 17 16
output:
15
result:
ok single line: '15'
Test #63:
score: 7
Accepted
time: 14ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 2 16 1 17 3 15 2 16 4 14 3 15 5 13 4 14 6 12 5 13 7 11 6 12 8 10 7 11 9 8 10 9
output:
16
result:
ok single line: '16'
Test #64:
score: 7
Accepted
time: 13ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 9 10 8 9 11 7 10 8 12 6 11 7 13 5 12 6 14 4 13 5 15 3 14 4 16 2 15 3 17 1 16 2
output:
15
result:
ok single line: '15'
Test #65:
score: 7
Accepted
time: 15ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 9 10 8 9 11 7 10 8 12 6 11 7 13 5 12 6 14 4 13 5 15 3 14 4 1 16 2 15 3 17 16 2
output:
16
result:
ok single line: '16'
Test #66:
score: 7
Accepted
time: 14ms
memory: 4608kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 1 17 2 16 3 15 4 14 5 13 6 12 7 11 8 10 9 1 17 2 16 3 15 4 14 5 13 6 12 7 11 8
output:
15
result:
ok single line: '15'
Subtask #4:
score: 0
Wrong Answer
Dependency #3:
100%
Accepted
Test #67:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 50 10 18 8 18 88 37 61 48 39 35 74 58 24 43 99 70 8 9 48 88 26 30 26 37 99 29 25 1 57 34 40 98 2...
output:
5
result:
wrong answer 1st lines differ - expected: '7', found: '5'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%