A. Review Site | Edu Round 107 Div.2

LONGNEW·2021년 7월 21일
0

CP

목록 보기
50/155

https://codeforces.com/contest/1511/problem/A
시간 2초, 메모리 256MB

input :

  • t (1≤t≤104)
  • n (1≤n≤50)
  • r1, r2, …, rn (1 ≤ ri ≤ 3)

output :

  • For each testcase print a single integer — the maximum total number of upvotes you can gather over both servers if you decide which server to send each reviewer to.
    서버 모두의 추천 개수의 최대 값을 출력하시오.

조건 :

  • type 1: a reviewer has watched the movie, and they like it — they press the upvote button;
    type 2: a reviewer has watched the movie, and they dislike it — they press the downvote button;
    type 3: a reviewer hasn't watched the movie — they look at the current number of upvotes and downvotes of the movie on the server they are in and decide what button to press. If there are more downvotes than upvotes, then a reviewer downvotes the movie. Otherwise, they upvote the movie.
    타입 1 : 평론가들이 영화를 시청하고 좋아했다. -> 추천
    타입 2 : 평론가들이 영화를 시청하고 싫어했다. -> 비추천
    타입 3 : 평론가가 아직 영화를 시청하지 않았다. 현재의 추천 혹은 비추천 수를 확인하고 어떤 버튼을 누를지 결정한다. 두 의견 중 더 많은 평론가가 속한 쪽을 선택한다.

  • Since you have two servers, you can actually manipulate the votes so that your movie gets as many upvotes as possible.
    2개의 서버를 운영하기 때문에 추천을 가장 많이 받기 위해 자신이 의도한대로 평론가를 움직이게 할 수 있다.


2개의 서버를 가지고 있는 것이 아주 좋은 힌트였다.
비추천의 경우 한 쪽으로 계속 모으고 그 외의 경우에는 계속 추천만 누르기 때문에
3과 1의 개수를 다 더해 출력하는 것이 우리가 원하는 정답이 된다.

import sys

t = int(sys.stdin.readline())
for _ in range(t):
    n = int(sys.stdin.readline())
    data = list(map(int, sys.stdin.readline().split()))

    cnt = 0
    for item in data:
        if item == 1 or item == 3:
            cnt += 1
    print(cnt)

0개의 댓글