QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#866775 | #8811. Heat Stroke | lgvc# | Compile Error | / | / | C++23 | 1.7kb | 2025-01-22 18:32:14 | 2025-01-22 18:32:15 |
Judging History
This is the latest submission verdict.
- [2025-01-22 18:32:15]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-01-22 18:32:14]
- Submitted
answer
#include <bits/stdc++.h>
//0 qian j ge
//1 hou j ge
#define INF 0x3f3f3f3f
int N,L,va[8009],c[8009],la[8009][8009],vc[100000009][2],su[8009];
std::vector<int> t[8009];
int sv(int n,int x,int y,int op) {
int id=x*(c[n]+1)+y+su[n-1];
if(n==N-1) {
if(x<c[n]&&(x-y)<va[n+1]) return INF;
return x;
}
if(vc[id][op]!=-1) {
return vc[id][op];
}
int ans=INF;
for(int xx=0;xx<=c[n+1];xx++) {
int l1=0,l2=0;
if(xx<c[n+1]) l2=t[n+1][xx+1]-1;else l2=L;
if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
int lim=std::min(l1,l2);
int tp1=la[lim][n],tp2=la[lim][n+1];
int vv=va[n+1];
if(op==1) vv-=std::min(x-y,tp1);
else vv-=(std::max(std::min(x,tp1),y)-y);
for(int yy=0;yy<=xx;yy++) {
int vt=vv-std::min(yy,tp2);
if((vt>=0)&&((xx==c[n+1]&&x==c[n])||(vt==0))) {
ans=std::min(ans,sv(n+1,xx,yy,0)+x);
}
}
for(int yy=0;yy<=xx;yy++) {
int vt=vv-std::max(std::min(xx,tp2),xx-yy)-(xx-yy);
if((vt>=0)&&((xx==c[n+1]&&x==c[n])||(vt==0))) {
ans=std::min(ans,sv(n+1,xx,yy,1)+x);
}
}
}
return vc[id][op]=ans;
}
signed main(void) {
memset(vc,-1,sizeof(vc));
scanf("%d",&N);
for(int i=1;i<=N;i++) {
scanf("%d",&va[i]);
t[i].push_back(0);
}
scanf("%d",&L);
for(int i=1;i<=L;i++) {
int x;
scanf("%d",&x);
t[x].push_back(i);
c[x]++;
for(int j=1;j<=N;j++) {
la[i][j]=la[i-1][j];
}
la[i][x]=t[x].size()-1;
}
for(int i=1;i<=N;i++) {
su[i]=su[i-1]+(c[n]+1)*(c[n]+1);
}
int ans=0x3f3f3f3f;
for(int i=0;i<=c[1];i++) {
for(int j=0;j<=i&&j<=va[1];j++) {
if((i==c[1])||(j==va[1])) ans=std::min(ans,sv(1,i,j,0));
if((i==c[1])||(j==va[1])) ans=std::min(ans,sv(1,i,j,1));
}
}
// printf("%d\n",sv(4,0,0,0));
printf("%d",L-ans);
}
Details
answer.code: In function ‘int main()’: answer.code:60:34: error: ‘n’ was not declared in this scope 60 | su[i]=su[i-1]+(c[n]+1)*(c[n]+1); | ^ answer.code:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d",&N); | ~~~~~^~~~~~~~~ answer.code:45:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("%d",&va[i]); | ~~~~~^~~~~~~~~~~~~ answer.code:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d",&L); | ~~~~~^~~~~~~~~ answer.code:51:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 51 | scanf("%d",&x); | ~~~~~^~~~~~~~~