[CCC 2023 J3] Special Event
题面翻译
你的公司需要开一场会议,一共有 5 5 5 天可以开会。这个公司有 N N N 位员工,每个员工的日程安排都不同,你作为一个公司的董事长,想要听取更多员工的意见,你需要知道哪几天能来开会的员工最多,你准备在这几天中选一天开会。
你需要实现一个程序,第一行输入一个
N
N
N(
1
≤
N
≤
20
1\leq N \leq 20
1≤N≤20),表示有
N
N
N 个员工,然后
N
N
N 行,每行
5
5
5 个字符,Y
表示该员工那天能来,.
表示不能,现在请你求出哪几天能来开会的员工最多,如果有多天,请以一个 ,
间隔。
题目描述
You are trying to schedule a special event on one of five possible days.
Your job is to determine on which day you should schedule the event, so that the largest number of interested people are able to attend.
输入格式
The first line of input will contain a positive integer N N N, representing the number of people interested in attending your event. The next N N N lines will each contain one person’s availability using one character for each of Day 1, Day 2, Day 3, Day 4, and Day 5(in that order).
The character Y
means the person is able to attend and a period (.
) means the person is
not able to attend.
The following table shows how the available 15 marks are distributed:
Marks | Description |
---|---|
6 | There will be exactly one day on which every person will be able to attend. |
6 | There will be exactly one day on which the largest number of people will be able to attend. |
3 | There might be more than one day on which the largest number of people will be able to attend. |
输出格式
The output will consist of one line listing the day number(s) on which the largest number of
interested people are able to attend.
If there is more than one day on which the largest number of people are able to attend,output all of these day numbers in increasing order and separated by commas (without spaces).
样例 #1
样例输入 #1
3
YY.Y.
...Y.
.YYY.
样例输出 #1
4
样例 #2
样例输入 #2
5
YY..Y
.YY.Y
.Y.Y.
.YY.Y
Y...Y
样例输出 #2
2,5
提示说明
主要思路就是先循环统计每天的开会人数,然后打擂台找到最大值,再找到哪些天是最大值,用逗号隔开输出即可。
本题采用捆绑测试。
- Subtask 1 1 1( 6 6 6 points):有且只有一天全部人都可以开会。
- Subtask 2 2 2( 6 6 6 points):有且只有一天开会人数最多。
- Subtask 3 3 3( 3 3 3 points):有可能有多天满足条件。
代码内容
// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[6],p[6];
int main()
{
ll n;
cin>>n;
for(ll i=1;i<=n;i++)
for(ll j=1;j<=5;j++)
{
char c;
cin>>c;
if(c=='Y') a[j]++;
}
ll mx=0;
for(ll i=1;i<=5;i++)
{
if(a[i]>mx)
mx=a[i];
}
ll cnt=0;
for(ll i=1;i<=5;i++)
{
if(a[i]==mx)
p[++cnt]=i; //统计哪几天是最大值。
}
for(ll i=1;i<cnt;i++)
cout<<p[i]<<",";
cout<<p[cnt];
return 0;
}