코딩로그
[백준/BOJ/C++] 20332번 Divvying Up 본문
[문제]
A solid competitive programming team can rack up a lot of prize money. Knowing how strong your team is, you are certain to win a lot of contests, so you had better sit down now and check that everybody will receive the same fair distribution of winnings.
You will participate in multiple contests, and at the end of each one receive a set amount of prize money. You can distribute any amount to each of the three members of your team each time, but by the end everyone must have the same amount of total winnings.
Can you distribute the winnings such that everyone gets an equal amount by the end?
[입력]
- One line containing the number of contests, $n$ ($1 \le n \le 10^4$).
- One line containing the prize purse for each contest, $w_1 \ldots w_n$ ($1 \le w \le 10^5$).
[출력]
Output yes if the winnings can be distributed equally between three contestants, otherwise no.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int contest, sum = 0;
cin >> contest;
for(int i = 0; i < contest; i++){
int input;
cin >> input;
sum += input;
}
if(sum % 3 == 0){
cout << "yes";
}
else
cout << "no";
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 17010번 Time to Decompress (0) | 2021.10.22 |
---|---|
[백준/BOJ/C++] 20499번 Darius님 한타 안 함? (0) | 2021.10.22 |
[백준/BOJ/C++] 21598번 SciComLove (0) | 2021.10.22 |
[백준/BOJ/C++] 21612번 Boiling Water (0) | 2021.10.22 |
[백준/BOJ/C++] 23234번 The World Responds (0) | 2021.10.22 |