#include <bits/stdc++.h>
using namespace std;
int W0, I0, T, D, I, A;
int newWeight, newBm;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> W0 >> I0 >> T >> D >> I >> A;
// not considering bm delta
newWeight = W0 + (I - (I0 + A)) * D;
if (newWeight > 0) cout << newWeight << " " << I0 << "\n";
else cout << "Danger Diet" << "\n";
// otherwise
newWeight = W0;
newBm = I0;
for (int d = 0; d < D; ++d) {
newWeight += I - (newBm + A);
if (abs(I - (newBm + A)) > T) {
if ((I - (newBm + A)) >= 0) newBm += (I - (newBm + A)) / 2;
else {
if ((I - (newBm + A))%2 == 0) newBm += (I - (newBm + A)) / 2;
else newBm += (I - (newBm + A)) / 2 - 1;
}
}
if (newWeight <= 0 || newBm <= 0) break;
}
if (newWeight <= 0 || newBm <= 0 || I0 - newBm < 0) cout << "Danger Diet";
else {
cout << newWeight << " " << newBm << " ";
cout << ((I0 - newBm > 0) ? "YOYO" : "NO");
}
return 0;
}
A 요요 시뮬레이션
19636번: 요요 시뮬레이션
다이어트 전 체중 W0이 100,000g, 에너지 섭취량 I0이 1,500 Kcal인 경우, 다이어트 전 기초 대사량은 에너지 섭취량과 같은 1500 Kcal이다. 데시는 운동을 하지 않으므로 다이어트 전 활동 대사량 A0은 0
www.acmicpc.net
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<string> title;
vector<int> power;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N >> M;
for (int i = 0; i < N; ++i) {
string t; int p;
cin >> t >> p;
title.push_back(t);
power.push_back(p);
}
for (int i = 0; i < M; ++i) {
int p; cin >> p;
int r = lower_bound(power.begin(), power.end(), p) - power.begin();
cout << title[r] << "\n";
}
return 0;
}
19637번: IF문 좀 대신 써줘
첫 번째 줄에는 칭호의 개수 N (1 ≤ N ≤ 105)과 칭호를 출력해야 하는 캐릭터들의 개수 M (1 ≤ M ≤ 105)이 빈칸을 사이에 두고 주어진다. (1 ≤ N, M ≤ 105) 두 번째 줄부터 N개의 줄에 각 칭
www.acmicpc.net
#include <bits/stdc++.h>
using namespace std;
int N, H, T, t, res;
bool found;
priority_queue<int> giant;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N >> H >> T;
for (int i = 0; i < N; ++i) {
int input; cin >> input;
giant.push(input);
}
if (giant.top() < H) {
cout << "YES" << "\n" << res << "\n";
found = true;
}
if (!found) {
while (++res && ++t <= T) {
int g = giant.top(); giant.pop(); giant.push(max(1, g / 2));
if (giant.top() < H) {
cout << "YES" << "\n" << res << "\n";
found = true; break;
}
}
}
if (!found) {
cout << "NO" << "\n" << giant.top() << "\n";
}
return 0;
}
19638번: 센티와 마법의 뿅망치
마법의 뿅망치를 센티의 전략대로 이용하여 거인의 나라의 모든 거인이 센티보다 키가 작도록 할 수 있는 경우, 첫 번째 줄에 YES를 출력하고, 두 번째 줄에 마법의 뿅망치를 최소로 사용한 횟수�
www.acmicpc.net
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int X, Y, M, m;
deque<pii> foe;
deque<pii> item;
vector<int> res;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> X >> Y >> M;
m = M;
for (int x = 0; x < X; ++x) {
int input; cin >> input;
foe.push_back({ input, x + 1 });
} sort(foe.begin(), foe.end());
for (int y = 0; y < Y; ++y) {
int input; cin >> input;
item.push_back({ input, y + 1 });
} sort(item.begin(), item.end());
while (!foe.empty() || !item.empty()) {
bool gfe = !foe.empty(), gie = !item.empty();
while (!foe.empty() && m > foe.back().first ) {
res.push_back(-1 * foe.back().second);
gfe = true;
m -= foe.back().first; foe.pop_back();
}
while (!item.empty() && (foe.empty() || m <= foe.back().first)) {
res.push_back(item.front().second);
gie = true;
m += item.front().first; item.pop_front();
m = min(m, M);
}
if (!gfe || !gie) break;
}
if (res.size() == X + Y) {
for (int r : res) cout << r << "\n";
}
else cout << 0;
return 0;
}
D 배틀로얄
19639번: 배틀로얄
첫 번째 줄에 X, Y, M (0 ≤ X, Y ≤ 100,000, 2 ≤ M ≤ 100,000)이 주어진다. M은 짝수다. 다음 X개의 줄에는 i번째 사람과 싸웠을 때 잃게 되는 체력이 주어진다. 이 수는 0 이상 M / 2 이하의 정수이다.
www.acmicpc.net
#include <bits/stdc++.h>
using namespace std;
struct T {
int d, h, l;
bool isDeca;
};
struct cmp {
bool operator()(const T& a, const T& b) {
if (a.d != b.d) {
return a.d < b.d;
}
if (a.h != b.h) {
return a.h < b.h;
}
return a.l > b.l;
}
};
int N, M, K, res;
vector<queue<T> > line;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N >> M >> K;
line.resize(M);
for (int i = 0; i < N; ++i) {
int d, h; cin >> d >> h;
line[i % M].push(T{ d, h, i % M, i == K });
}
priority_queue<T, vector<T>, cmp > pq;
for (int i = 0; i < M; ++i) {
if (line[i].empty()) continue;
pq.push(line[i].front()); line[i].pop();
}
while (++res) {
T req = pq.top(); pq.pop();
// cout << req.d << " " << req.h << " " << req.l << " " << req.isDeca << "\n";
if (req.isDeca) {
cout << res - 1;
break;
}
if (!line[req.l].empty()) {
pq.push(line[req.l].front()); line[req.l].pop();
}
}
return 0;
}
E 화장실의 규칙
19640번: 화장실의 규칙
위와 같이 줄을 선 경우를 생각해보자. (x, y) 는 사원의 근무 일수가 x, 화장실이 급한 정도가 y임을 나타낸다. [x, y]는 해당 사원이 데카임을 의미한다. 즉, 위의 그림에서 데카는 3번 사원이다.
www.acmicpc.net
#include <bits/stdc++.h>
using namespace std;
long long L, Ml, Mk, C;
long long kh = 0, ds = 0;
long long Z[3000002];
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> L >> Ml >> Mk >> C;
for (int i = 1; i <= L; ++i) cin >> Z[i];
for (int q = 0;; q++) {
ds += Mk;
if (kh <= L && Z[kh + 1] > ds) {
if (C > 0) {
C--;
ds -= Mk;
Z[kh + 1] = 0;
}
}
if (Z[kh + 1] > ds) {
cout << "NO";
break;
}
if (kh == L) {
cout << "YES";
break;
}
kh++;
}
return 0;
}
19644번: 좀비 떼가 기관총 진지에도 오다니
킬로와 헥토는 좀비 떼로부터 탄약고를 사수하는 데에 성공했다. 포상 휴가나 조기 전역을 기대했으나 좀비 사태로 인해 계엄령이 선포되면서 오히려 전역이 연기되고 기관총 진지에 배치되었�
www.acmicpc.net
#include <bits/stdc++.h>
using namespace std;
int N, res;
vector<int> sol[1001];
vector<bool> visit[1001];
int rv[1001];
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N;
for (int i = 0; i < N; ++i) {
int C, input; cin >> C;
for (int c = 0; c < C; ++c) {
cin >> input;
sol[i].push_back(input);
}
}
int cnt = 0;
bool good = true;
while (good && cnt < N) {
good = false;
for (int i = 0; i < N; ++i) {
if (sol[i].size() == 1) {
int f = sol[i][0];
rv[i] = f;
cnt++;
good = true;
for (int j = 0; j < N; ++j) sol[j].erase(remove(sol[j].begin(), sol[j].end(), f), sol[j].end());
continue;
}
}
}
if (cnt == N) {
cout << 1 << "\n";
for (int i = 0; i < N; ++i) cout << rv[i] << " ";
}
else {
cout << -1;
}
return 0;
}
19647번: Unique Solution
만약에 해당 후보군 만으로 모든 문제의 답을 유일하게 정할 수 있으면 첫 번째 줄에 1을 출력하고, 그 다음 줄에 각 문제에 대한 정답 N개를 1번 문제부터 순서대로 공백으로 구분해서 출력한다.
www.acmicpc.net
E 52분 - B 62분 - C 77분 - A 120분 - L 175분 - D 223분 - I 295분
7문제 풀었다.
'알고리즘 > 대회 참여' 카테고리의 다른 글
shake! 2020 참여 (0) | 2021.01.25 |
---|---|
2020 인하대학교 프로그래밍 경진대회(IUPC) 참여 (0) | 2021.01.10 |
Good Bye, BOJ 2020! 특별상 (0) | 2020.12.31 |
ICPC Seoul Regional 2020 예선 참여 (0) | 2020.10.11 |
2020 IGRUS Newbie Programming Contest 참여 (0) | 2020.09.27 |
댓글