目前已经用题解的方法过了,这是自己写的代码,各位大佬行行好,帮帮我吧QAQ
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int t,n,m,a[105][105],cnt[105];
struct node{
int v,id;
}b[105];
bool cmp(node e,node f){
return e.v>f.v;
}
int main(){
scanf("%d %d %d",&t,&n,&m);
for(int i = 1;i <= n;i++)scanf("%d",&a[1][i]);
for(int i = 2;i <= t;i++){
for(int j = 1;j <= n;j++){
scanf("%d",&a[i][j]);
b[j].v=a[i][j]-a[i-1][j];
b[j].id=j;
}
sort(b+1,b+n+1,cmp);
int j=1;
while(b[j].v>0 && m){
cnt[b[j].id]+=m/a[i-1][b[j].id];
m%=a[i-1][b[j].id];
j++;
}
for(int j = 1;j <= n;j++){
if(cnt[j]){
m+=cnt[j]*a[i][j];
cnt[j]=0;
}
}
}
printf("%d",m);
return 0;
}
(我的首个WA数据)
input:
4 3 96
28 46 67
11 69 32
16 36 38
19 36 52
output:
272