QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667358#9470. Cats and Fishzwu2021016689AC ✓0ms3812kbC++17813b2024-10-22 22:24:542024-10-22 22:25:02

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 22:25:02]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3812kb
  • [2024-10-22 22:24:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define dg(x) cout<<#x<<'='<<x<<'\n';

int n,m,x;
const int N=2e5+10;
int a[N];

inline void solve()
{
	vector<int>vis(n+5);
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	int cnt=0;
	for(int i=1;i<=x;i++){
		for(int j=1;j<=n;j++){
			if(m==0) break;
			if(a[j]==1){
				m--;
				continue;
			}
			if(i%a[j]){
				if(vis[j]==0){
					vis[j]=1;
					cnt++;
					m--;
				}
			}
			else{
				cnt--;
				vis[j]=0;
			}
		}
	}
	cout<<m<<' '<<cnt<<'\n';
}

/*
2 2 12
1 13

2 1 1
1
8 3 5
1 3	4 
4 5 1
5 4	3 2	1

2 1 1
1
8 3 5
1 3 4
4 5 1
5 4 3 2 1
*/

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t=1;
	//cin>>t;
	while(cin>>m>>n>>x) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

2 1 1
1
8 3 5
1 3 4
4 5 1
5 4 3 2 1

output:

1 0
0 1
0 3

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

1 1 10
1
14 3 10
1 40 50
8 2 7
12 13
1 1 1
2
12 2 11
8 3
2 2 12
24 1
562 8 232
17 26 800 12 77 32 11 2
562 8 1
17 26 800 12 77 32 11 1
3656 13 123
1887 26 800 12 77 32 11 1 77 32 77 32 155

output:

0 0
2 2
6 2
0 1
6 2
0 1
368 7
554 7
3484 12

result:

ok 9 lines