Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 문자열
- 투 포인터
- 재귀
- 우선순위 큐
- 유니티
- c++
- 시뮬레이션
- XR Interaction Toolkit
- 그래프
- 트리
- 스택
- ue5
- 백트래킹
- 브루트포스
- VR
- BFS
- Team Fortress 2
- 알고리즘
- 그리디 알고리즘
- Unreal Engine 5
- 누적 합
- 유니온 파인드
- 다이나믹 프로그래밍
- 다익스트라
- 백준
- 자료구조
- 수학
- 구현
- DFS
- 정렬
Archives
- Today
- Total
1일1알
백준 11637번 인기 투표 C++ 본문
https://www.acmicpc.net/problem/11637
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int maxVal = 0;
int sum = 0;
int maxIdx = -1;
bool same = false;
for (int i = 1; i <= n; i++) {
int val;
cin >> val;
sum += val;
if (val == maxVal) {
same = true;
}
else if (val > maxVal) {
maxIdx = i;
maxVal = val;
same = false;
}
}
if (same) cout << "no winner\n";
else {
sum -= maxVal;
if (sum < maxVal) cout << "majority winner " << maxIdx << "\n";
else cout << "minority winner " << maxIdx << "\n";
}
}
}
'알고리즘' 카테고리의 다른 글
백준 16938번 캠프 준비 C++ (0) | 2023.05.21 |
---|---|
백준 5002번 도어맨 C++ (0) | 2023.05.20 |
백준 16509번 장군 C++ (0) | 2023.05.16 |
백준 17413번 단어 뒤집기 C++ (0) | 2023.05.15 |
백준 17085번 십자가 2개 놓기 C++ (1) | 2023.05.14 |