Problem - A - Codeforces
codeforces.com
제일 많은 수의 공
- 제목
Colored Balls: Revisited
- 조건
time limit per test : 2 second
memory limit per test : 256 megabytes
input : standard input
output : standard output
- 문제
The title is a reference to the very first Educational Round from our writers team, Educational Round 18.
There is a bag, containing colored balls. There are n different colors of balls, numbered from 1 to n. There are cnti balls of color i in the bag. The total amount of balls in the bag is odd (e. g. cnt1+cnt2+⋯+cntn is odd).
In one move, you can choose two balls with different colors and take them out of the bag.
At some point, all the remaining balls in the bag will have the same color. That's when you can't make moves anymore.
Find any possible color of the remaining balls.
- 입력
The first line contains a single integer t (1≤t≤1000) — the number of testcases.
The first line of each testcase contains a single integer n (1≤n≤20) — the number of colors.
The second line contains n integers cnt1,cnt2,…,cntn (1≤cnti≤100) — the amount of balls of each color in the bag.
The total amount of balls in the bag is odd (e. g. cnt1+cnt2+⋯+cntn is odd).
- 출력
For each testcase, print a single integer — any possible color of the remaining balls, after you made some moves and can't make moves anymore.
예제 입력1 | 예제 출력1 |
3 3 1 1 1 1 9 2 4 7 |
3 1 2 |
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SIZE 100000
int main() {
fastio;
int tc, sz, cnt;
cin >> tc;
while(tc--){
cin >> sz;
vector<pair<int, int>> vc;
for(int n = 0 ; n < sz ; n++){
cin >> cnt;
vc.push_back(make_pair(cnt, n + 1));
}
sort(vc.begin(), vc.end());
cout << vc[vc.size() - 1].second << endl;
}
return 0;
}