一、AtCoder
1.Attack Survival
题意:
Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players’ scores in a game, which proceeds as follows.
A game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.
When a player correctly answers a question, each of the other N−1 players receives minus one (−1) point. There is no other factor that affects the players’ scores.
At the end of a game, the players with 0 points
or lower are eliminated, and the remaining players survive.
In the last game, the players gave a total of Q correct answers, the i-th of which was given by Player Ai. For Kizahashi, write a program that determines whether each of the N players survived this game.
输出几轮得分后每个人是否存活下来
变量范围:
- All values in input are integers.
- 2≤N≤10^5
- 1≤K≤10^9
- 1≤Q≤10^5
- 1≤Ai≤N(1≤i≤Q)
输入:
N K Q
A1
A2
.
.
.
AQ
输出:
Print N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.
样例输入:
6 3 4
3
1
3
2
样例输出:
No
No
Yes
No
No
No
解题思路:
刚开始就是模拟题目的意思,但是超时了,后来用b数组记录一下他们得分的次数,就过了。
程序代码(TLE):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
int n,k,Q;
cin>>n>>k>>Q;
for(int i=1;i<=n;i++)
a[i]=k;
for(int i=1;i<=Q;i++){
int temp;
cin>>temp;
for(int j=1;j<=n;j++){
if(j!=temp)
a[j]--;
}
}
for(int i=1;i<=n;i++){
if(a[i]<=0)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
return 0;
}
程序代码(AC):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int b[N];
int mai