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 | 31 |
Tags
- ๊ตฌํ
- thymeleaf
- Spring
- ๋ฐฑํธ๋ํน
- OS
- java
- error
- BFS
- ์์ ์ ๋ ฌ
- dfs
- ๋ฐ์ดํฌ์คํธ๋ผ
- GCP
- ๋์ ํฉ
- ์ด๋ถ ํ์
- ์คํ
- web
- c++
- ์ฐ์ ์์ ํ
- ๋ถํ ์ ๋ณต
- dynamic debugging
- JPA
- ์ต๋จ ๊ฒฝ๋ก
- CVE
- DP
- Reversing
- ์๋ฎฌ๋ ์ด์
- ๋ฌธ์์ด
- ๋งต
- ์ฌ๊ท
- ๊ทธ๋ฆฌ๋
Archives
- Today
- Total
hades
[Baekjoon] 1138๋ฒ: ํ ์ค๋ก ์๊ธฐ ๋ณธ๋ฌธ
๐ฅ ๋ฌธ์
https://www.acmicpc.net/problem/1138
๐ ์ค๊ณ
ํฐ ๊ฒ์ ๋จผ์ ๋ฐฐ์นํ๋ฉด, ์ ํ์ ํญ์ด ๋ง๊ธฐ ๋๋ฌธ์ ์ข์ง ์๋ค.
์์ ๊ฒ, ์ฆ ์์ ์๋ ๊ฒ๋ถํฐ ๋ฐฐ์นํ๋ค. ์์ ๊ฒ๋ถํฐ ๋ฐฐ์นํ๊ธฐ ๋๋ฌธ์ ๋ฐ๋ณต๋ฌธ์ผ๋ก ์ํํ๋ฉด์ ํฐ ๊ฒ์ด ์๋ ์ํฉ์ ๊ณ ๋ คํ์ง ์์๋ ๋๋ค. ์ํํ๋ ๊ณผ์ ์์ ์ฑ์์ง์ง ์์์ 0์ด๋ผ๋ฉด, ์์ ๋ณด๋ค ํฐ ์ฌ๋์ ์์์ 1์ ๋บ๋ค. ๊ณ์ํด์ ๋นผ๋ค๊ฐ -1์ด ๋๋ฉด ๋ฐฐ์นํ๋ค.
๐ ํ์ด
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, smaller;
vector<int> v(10);
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> smaller;
for (int j = 0; j < n; j++) {
if (v[j] > i || v[j] == 0) {
smaller -= 1;
}
if (smaller == -1) {
v[j] = i;
break;
}
}
}
for (int i = 0; i < n; i++) {
cout << v[i] << " ";
}
return 0;
}
'๐ PS > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Baekjoon] 16928๋ฒ: ๋ฑ๊ณผ ์ฌ๋ค๋ฆฌ ๊ฒ์ (2) | 2024.10.15 |
---|---|
[Baekjoon] 1766๋ฒ: ๋ฌธ์ ์ง (0) | 2024.09.30 |
[Baekjoon] 2252๋ฒ: ์ค์ธ์ฐ๊ธฐ (0) | 2024.09.23 |
[Baekjoon] 2143๋ฒ: ๋ ๋ฐฐ์ด์ ํฉ (0) | 2024.09.20 |
[Baekjoon] 1202๋ฒ: ๋ณด์ ๋๋ (0) | 2024.09.19 |