#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 요요 시뮬레이션
#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;
}
#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;
}
#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 배틀로얄
#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 화장실의 규칙
#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;
}
#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;
}
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 |
댓글