求助,不知道咋改
查看原帖
求助,不知道咋改
155492
Retrospective楼主2020/10/23 13:18

第一次改前  十分  {\color{green}\colorbox{white}{第一次改前~~十分~~}}

#include<bits/stdc++.h>
using namespace std;
long long n,t,k,ts,ji,ans;
long long a,b[100005];
int main()
{
	cin>>n;
	for(int nn=1;nn<=n;nn++)
	{
		ans=0;
		cin>>t>>k;
		ts+=t;
		if(ts>86400) memset(b,0,sizeof(b)),ts=ts-86400;
		for(int i=1;i<=k;i++)
		{
			cin>>a;
			b[a]++;
		}
		for(int i=1;i<=100005;i++)
		{
			if(b[i]>0) ans++; 
		}
		cout<<ans<<endl;
	}
	return 0;	
} 
/*
86400
*/

第一次改后  爆零  {\color{red}\colorbox{green}{第一次改后~~爆零~~}}

#include<bits/stdc++.h>
using namespace std;
long long n,t,k,ts,ji,ans;
long long a[100005][100005],b[100005];//这有问题
int main()
{
	cin>>n;
	for(int nn=1;nn<=n;nn++)
	{
		ans=0;
		cin>>t>>k;
		ts+=t;
		a[0][0]=t;
		a[0][1]=k; 
		if(ts>86400)
		{
			memset(b,0,sizeof(b));
			ts=ts-86400;
			for(int i=1;i<=n;i++)
			{
				if(a[0][0]<=ts)
				{
					a[i][a[0][1]]=0;
				}
				else break;
			}	
		}
		for(int i=1;i<=k;i++)
		{
			cin>>a[nn][k];
			b[a[nn][k]]++;
		}
		for(int i=1;i<=100005;i++)
		{
			if(b[i]>0) ans++; 
		}
		cout<<ans<<endl;
	}
	return 0;	
} 

2020/10/23 13:18
加载中...