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 |
Tags
- 스택
- VR
- 투 포인터
- 그리디 알고리즘
- BFS
- 재귀
- 다이나믹 프로그래밍
- DFS
- 브루트포스
- 유니온 파인드
- 문자열
- 다익스트라
- 시뮬레이션
- 그래프
- 백트래킹
- 백준
- 알고리즘
- 수학
- 트리
- c++
- ue5
- 우선순위 큐
- 누적 합
- Unreal Engine 5
- XR Interaction Toolkit
- 유니티
- 정렬
- 자료구조
- 구현
- Team Fortress 2
Archives
- Today
- Total
1일1알
백준 1205번 등수 구하기 C++ 본문
더 쉬운 방법이 있을 수 있겠지만 생각보다 실수할 여지가 많아보이는 문제였다.
#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 <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, myScore, p;
bool first = true;
bool firstSame = true;
cin >> n >> myScore >> p;
int rank = n + 1;
int renderRank = n + 1;
vector<int> scores(n + 1);
for (int i = 1; i <= n; i++) {
cin >> scores[i];
if (myScore == scores[i]) {
renderRank = i + 1;
if (firstSame) {
rank = i;
first = false;
firstSame = false;
}
}
if (myScore > scores[i] && first) {
renderRank = i;
rank = i;
first = false;
}
}
if (renderRank > p) rank = -1;
cout << rank;
};
'알고리즘' 카테고리의 다른 글
백준 1195번 킥다운 C++ (0) | 2022.04.12 |
---|---|
백준 1063번 킹 C++ (0) | 2022.04.11 |
백준 6603번 로또 C++ (0) | 2022.04.09 |
백준 16236번 아기 상어 C++ (0) | 2022.04.07 |
백준 1389번 케빈 베이컨의 6단계 법칙 (0) | 2022.04.06 |