Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
23895 | fyq & jbh's LCA | 【BJ】T3 | C++ | 运行超时 | 25 | 4000 MS | 11972 KB | 1125 | 2023-12-03 19:53:54 |
//25pts #include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define m_p make_pair #define p_b push_back using namespace std; typedef long long ll; const int maxn=1e5+10; inline ll read(){ ll x=0;short t=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,k,q,a[maxn][10];ll dp[2][10][maxn]; void slv(){ n=read(),k=read(),q=read(); up(i,1,k)up(j,1,n)a[j][i]=read(); up(i,1,k)up(j,0,n)dp[1][i][j]=-1e18;dp[1][1][1]=a[1][1]; up(t,2,n){ int op=t&1; up(i,1,k)dp[op][i][0]=-1e18; up(i,1,k)up(j,1,n){ dp[op][i][j]=max(dp[!op][((i==1)?k:(i-1))][j-1],dp[!op][i][j])+a[t][i]; } }while(q--){ int x=read();ll res=0; up(i,1,k)res=max(res,dp[n&1][i][x]); cout<<res<<'\n'; } }int main(){ // freopen("division.in","r",stdin); // freopen("division.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }