QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882265#8811. Heat StrokeMatutino0 1412ms1006664kbC++173.0kb2025-02-04 22:52:422025-02-04 22:52:43

Judging History

This is the latest submission verdict.

  • [2025-02-04 22:52:43]
  • Judged
  • Verdict: 0
  • Time: 1412ms
  • Memory: 1006664kb
  • [2025-02-04 22:52:42]
  • 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;}
inline int min(reg int x,reg int y){return x<y?x:y;}
inline int max(reg int x,reg int y){return x>y?x:y;}
const int N=8010;
int n,L,C[N],f[2][N][N],pre[N][N],suf[N][N],sum[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));
    reg int now=0;
    for (reg int i=0;i<=n+1;i++){
        if (C[1]!=0&&(C[1]>vc[1].size()||vc[1][C[1]-1]>i)) continue;
        f[0][0][i]=0;
    }
    f[0][0][n+1]=0;
    memset(pre,-0x3f,sizeof(pre)),memset(suf,-0x3f,sizeof(suf));
    for (reg int i=1;i<L;i++){
        now^=1;
        for (reg int j=0;j<=C[i]&&j<=vc[i-1].size();j++){
            for (reg int k=0;k<=n+1;k++) sum[j][k]=f[now^1][j][k];
            for (reg int k=1;k<=n+1;k++) cmax(sum[j][k],sum[j][k-1]);
        }
        for (reg int x=0;x<=C[i+1]&&x<=vc[i].size();x++) for (reg int k=0;k<=n;k++){
            reg int p=std::upper_bound(vc[i].begin(),vc[i].end(),k)-vc[i].begin()-1;
            // if (p!=vc[i].size()-1) std::cerr<<"<< "<<i<<"\n";
            if (p+1>=x) cmax(suf[x][k],f[now^1][max(0,C[i]-(p+1-x))][k]+vc[i].size()-1-p);
        }
        for (reg int y=0;y<=n+1;y++) for (reg int j=0;j<=C[i]&&j<=vc[i-1].size();j++){
            reg int p=std::upper_bound(vc[i].begin(),vc[i].end(),y)-vc[i].begin()-1;
            // if (y==n+1) std::cerr<<i<<" "<<j<<" "<<sum[j][y]<<"\n";
            if (C[i]-j<=p+1) cmax(f[now][min(p+1-(C[i]-j),C[i+1])][y],sum[j][y]+vc[i].size()-1-p);
        }
        for (reg int j=0;j<=C[i]&&j<=vc[i].size();j++){
            for (reg int x=0;x<=vc[i].size()&&x<=C[i+1];x++)
                cmax(pre[x][x?vc[i][x-1]:0],f[now^1][j][n+1]);
            memset(f[now^1][j],-0x3f,sizeof(f[now^1][j]));
        }
        for (reg int x=0;x<=C[i+1]&&x<=vc[i].size();x++){
            for (reg int y=1;y<=n+1;y++) cmax(pre[x][y],pre[x][y-1]);
            for (reg int y=n;y>=0;y--) cmax(suf[x][y],suf[x][y+1]);
            for (reg int y=0;y<=n;y++)if ((x?vc[i][x-1]:0)<=y){
                if (C[i+1]!=x&&(C[i+1]-x>vc[i+1].size()||vc[i+1][C[i+1]-x-1]>y)){
                    f[now][x][y]=-1e9; 
                    continue;
                }
                cmax(f[now][x][y],pre[x][y]),cmax(f[now][x][y],suf[x][y]);
            }
            cmax(f[now][x][n+1],pre[x][n+1]),cmax(f[now][x][n+1],suf[x][n+1]);       
            memset(pre[x],-0x3f,sizeof(pre[x])),memset(suf[x],-0x3f,sizeof(suf[x]));
        } 
    }
    reg int ans=0;
    for (reg int i=0;i<=n;i++) cmax(ans,f[now][C[L]][i]);
    for (reg int i=0;i<=C[L];i++) cmax(ans,f[now][i][n+1]);
    printf("%d\n",ans);
    return 0;
}  

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 42ms
memory: 1006596kb

input:

2
0 0
1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 6
Accepted
time: 35ms
memory: 1006476kb

input:

2
0 1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 34ms
memory: 1006412kb

input:

2
1 0
1
1

output:

0

result:

ok single line: '0'

Test #4:

score: 6
Accepted
time: 28ms
memory: 1006448kb

input:

2
1 1
1
1

output:

0

result:

ok single line: '0'

Test #5:

score: 6
Accepted
time: 32ms
memory: 1006400kb

input:

2
2 2
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: 6
Accepted
time: 36ms
memory: 1006300kb

input:

2
1 1
2
1 1

output:

0

result:

ok single line: '0'

Test #7:

score: 6
Accepted
time: 25ms
memory: 1006360kb

input:

2
2 2
2
1 1

output:

0

result:

ok single line: '0'

Test #8:

score: 6
Accepted
time: 37ms
memory: 1006544kb

input:

2
3 3
2
1 1

output:

0

result:

ok single line: '0'

Test #9:

score: 6
Accepted
time: 34ms
memory: 1006472kb

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:

3

result:

ok single line: '3'

Test #10:

score: 6
Accepted
time: 275ms
memory: 1006440kb

input:

2
1749 1749
3500
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:

2

result:

ok single line: '2'

Test #11:

score: 6
Accepted
time: 1412ms
memory: 1006516kb

input:

2
3999 3999
8000
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:

2

result:

ok single line: '2'

Test #12:

score: 6
Accepted
time: 32ms
memory: 1006664kb

input:

2
1 1
8000
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 1 1...

output:

7998

result:

ok single line: '7998'

Test #13:

score: 6
Accepted
time: 53ms
memory: 1006604kb

input:

2
0 0
8000
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 1 1...

output:

8000

result:

ok single line: '8000'

Test #14:

score: 6
Accepted
time: 26ms
memory: 1006584kb

input:

3
0 1 1
2
1 2

output:

0

result:

ok single line: '0'

Test #15:

score: 6
Accepted
time: 44ms
memory: 1006464kb

input:

3
1 1 1
3
1 2 2

output:

1

result:

ok single line: '1'

Test #16:

score: 6
Accepted
time: 33ms
memory: 1006376kb

input:

3
1 2 0
3
1 1 2

output:

1

result:

ok single line: '1'

Test #17:

score: 6
Accepted
time: 29ms
memory: 1006604kb

input:

3
1 2 0
3
1 2 2

output:

1

result:

ok single line: '1'

Test #18:

score: 6
Accepted
time: 43ms
memory: 1006492kb

input:

3
1 3 0
4
1 1 1 2

output:

1

result:

ok single line: '1'

Test #19:

score: 6
Accepted
time: 25ms
memory: 1006544kb

input:

4
0 2 1 1
4
1 1 2 3

output:

0

result:

ok single line: '0'

Test #20:

score: 6
Accepted
time: 40ms
memory: 1006372kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17

output:

15

result:

ok single line: '15'

Test #21:

score: 0
Wrong Answer
time: 350ms
memory: 1006544kb

input:

8000
0 2 0 0 0 0 0 0 1 0 0 2 1 1 0 1 1 0 2 2 0 0 0 1 1 0 0 0 0 1 1 1 2 3 0 2 2 0 0 1 0 1 2 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 2 0 0 0 0 0 1 0 1 1 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 2 0 3 2 0 0 0 0 0 1 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 3 0...

output:

975

result:

wrong answer 1st lines differ - expected: '843', found: '975'

Subtask #2:

score: 0
Wrong Answer

Test #33:

score: 7
Accepted
time: 32ms
memory: 1006508kb

input:

3
1 1 1
3
1 2 1

output:

1

result:

ok single line: '1'

Test #34:

score: 7
Accepted
time: 26ms
memory: 1006384kb

input:

3
1 1 1
3
2 1 2

output:

1

result:

ok single line: '1'

Test #35:

score: 7
Accepted
time: 37ms
memory: 1006476kb

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: 31ms
memory: 1006400kb

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

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:

2

result:

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

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%