QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#881983#8811. Heat StrokeMatutino0 60ms9116kbC++171.9kb2025-02-04 20:22:052025-02-04 20:22:05

Judging History

This is the latest submission verdict.

  • [2025-02-04 20:22:05]
  • Judged
  • Verdict: 0
  • Time: 60ms
  • Memory: 9116kb
  • [2025-02-04 20:22:05]
  • Submitted

answer

#include<bits/stdc++.h>
#define reg register
// #define int long long
inline int read(){
    reg int x=0,k=1; reg char ch=getchar();
    while (ch<'0'||ch>'9') (ch=='-')&&(k=-1),ch=getchar();
    while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*k;
}
inline bool cmax(reg int &x,reg int y){return x<y?x=y,1:0;}
const int N=110;
int n,L,C[N],f[N][N][N];
std::vector<int> vc[N];
signed main(){
    L=read(); for (reg int i=1;i<=L;i++) C[i]=read();
    n=read(); for (reg int i=1;i<=n;i++) vc[read()].push_back(i);
    memset(f,-0x3f,sizeof(f));
    for (reg int i=0;i<=n+1;i++) f[0][0][i]=0;
    for (reg int i=1;i<L;i++){
        for (reg int j=0;j<=C[i];j++) for (reg int k=1;k<=n;k++)if (f[i-1][j][k]>=0){
            if (C[i]-j>vc[i].size()) continue;
            if (C[i]-j&&vc[i][C[i]-j-1]>k) continue; 
            for (reg int x=0;x+C[i]-j<=vc[i].size()&&x<=C[i+1];x++){
                reg int p=x+C[i]-j;
                if (p<vc[i].size()&&vc[i][p]<k) continue;
                // std::cerr<<"<< "<<x<<"\n";
                for (reg int y=(p?vc[i][p-1]:0);y<(p==vc[i].size()?n+1:vc[i][p]);y++){
                    // if (vc[i].size()-p==1) std::cerr<<"from "<<i<<" "<<j<<" "<<k<<" "<<"to "<<x<<" "<<y<<"\n";
                    cmax(f[i][x][y],f[i-1][j][k]+vc[i].size()-p);
                }
                cmax(f[i][x][n+1],f[i-1][j][k]);
            } 
        } 
        for (reg int j=0;j<=C[i];j++){
            for (reg int x=0;x<=vc[i].size()&&x<=C[i+1];x++) 
                for (reg int y=x?vc[i][x-1]:0;y<=n+1;y++) cmax(f[i][x][y],f[i-1][j][n+1]);
        }
    }
    reg int ans=0;
    for (reg int i=0;i<=n;i++){
        cmax(ans,f[L-1][C[L]][i]);
        // if (f[L-1][C[n]][i]==1) std::cerr<<"<< "<<i<<"\n";
    }
    for (reg int i=0;i<=C[L];i++){
        cmax(ans,f[L-1][i][n+1]);
        // if (f[L-1][i][n+1]==1) std::cerr<<"<< "<<i<<"\n";
    }
    printf("%d\n",ans);
    return 0;
}  

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 1ms
memory: 9096kb

input:

2
0 0
1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 6
Accepted
time: 0ms
memory: 8932kb

input:

2
0 1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 0ms
memory: 8832kb

input:

2
1 0
1
1

output:

0

result:

ok single line: '0'

Test #4:

score: 6
Accepted
time: 0ms
memory: 8956kb

input:

2
1 1
1
1

output:

0

result:

ok single line: '0'

Test #5:

score: 6
Accepted
time: 1ms
memory: 9116kb

input:

2
2 2
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: 6
Accepted
time: 0ms
memory: 8928kb

input:

2
1 1
2
1 1

output:

0

result:

ok single line: '0'

Test #7:

score: 6
Accepted
time: 0ms
memory: 8992kb

input:

2
2 2
2
1 1

output:

0

result:

ok single line: '0'

Test #8:

score: 6
Accepted
time: 0ms
memory: 8912kb

input:

2
3 3
2
1 1

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Wrong Answer
time: 60ms
memory: 8832kb

input:

2
298 299
600
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 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 ...

output:

111789

result:

wrong answer 1st lines differ - expected: '3', found: '111789'

Subtask #2:

score: 0
Wrong Answer

Test #33:

score: 7
Accepted
time: 0ms
memory: 9104kb

input:

3
1 1 1
3
1 2 1

output:

1

result:

ok single line: '1'

Test #34:

score: 7
Accepted
time: 0ms
memory: 9076kb

input:

3
1 1 1
3
2 1 2

output:

1

result:

ok single line: '1'

Test #35:

score: 7
Accepted
time: 0ms
memory: 8932kb

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: 8920kb

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: 0ms
memory: 8980kb

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: 0ms
memory: 8976kb

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: 0
Wrong Answer
time: 1ms
memory: 8916kb

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:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

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%