60分RE求助

P1190 [NOIP2010 普及组] 接水问题

@[alfie_gogo](/user/760071) s数组开小了
by 114514514htz @ 2024-08-22 16:32:56


@[alfie_gogo](/user/760071) s开到10005
by zhizhenyaohanyu @ 2024-08-22 16:34:11


开和w数组一样就行了
by dream_dad @ 2024-08-22 16:34:37


亲测( ~~确定~~ )
by dream_dad @ 2024-08-22 16:35:32


@[alfie_gogo](/user/760071) 这题模拟就好了 一秒一秒模拟 ```cpp #include<bits/stdc++.h>//T2 #define inf 0x3f3f3f3f using namespace std; int n,m,t,s,f; int w[10001],a[10001],p[10001]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); //freopen("water.in","r",stdin); //freopen("water.out","w",stdout); cin>>n>>m; for(int i=1;i<=n;i++){ cin>>w[i]; }for(int i=1;i<=m;i++){ p[i]=i; }t=m+1; for(int sec=1;;sec++){ for(int i=1;i<=m;i++){ a[p[i]]++; } for(int i=1;i<=m;i++){ if(a[p[i]]==w[p[i]]){ s++; if(s==n){ cout<<sec; return 0; } if(!f){ p[i]=t; if(t==n){ f=1; } } if(t<n){ t++; } } } } return 0; } ``` 写的不好,请见谅
by qz5zwangzihan1 @ 2024-08-22 16:37:06


@[alfie_gogo](/user/760071) 确实是数组大小的问题
by jyulong @ 2024-08-22 16:37:06


谢谢各位,AC了,确实是s的数组大小问题。但其实是我把最后一个循环的m写成n了()
by alfie_gogo @ 2024-08-22 17:41:00


|