728x90
반응형
Codeforces Round #895 (Div. 3)
문제 세트는 여기서 확인할 수 있다.
문제
A. Two Vessels (AC / 7 min)
더보기
a, b 중 큰 수와 작은 수를 정해놓고 작은 수와 큰 수에 각각 c를 더하고 빼면서 몇 번 만에 같아지는지 구하는 문제다.
단순 시뮬레이션.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int small = a > b ? b : a;
int big = a > b ? a : b;
int cnt = 0;
while (small < big) {
cnt++;
big -= c;
small += c;
}
cout << cnt << '\n';
}
return 0;
}
B.The Corridor or There and Back Again (AC / 30 min)
더보기
d번 칸에 있는 트랩은 d - 1 + s초에 활성화된다. 이를 t라 한다.
k를 몇 번째 칸까지 갈 수 있는지로 본다면, 1부터 시작한다.
그럼 k번째 칸까지 간다면 가는데 걸리는 시간은 k - 1초, k에서 트랩으로 돌아가는 시간 k - d초(단, k > d; 아닐경우 반드시 만족).
위 두 시간의 합이 트랩이 활성화되는 t보다 작으면 k번째 칸까지는 갈 수 있다는 뜻이다.
k를 늘려가며 확인하고 불가능한 경우에서 멈춘다. 이 과정을 모든 트랩에 대해 해보고 최솟값을 출력한다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, ans = INT_MAX;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
int d, s;
cin >> d >> s;
int t = d - 1 + s;
int k = 1;
while (k - 1 + k - d < t)
k++;
ans = min(ans, k - 1);
}
cout << ans << '\n';
}
return 0;
}
C.Non-coprime Split (WA)
더보기
l ≤ a + b ≤ r, gcd(a, b) ≠ 1
위 두 조건을 만족하는 a와 b를 찾는 문제.
문제에 대해 생각만 하다가 결국 못풀었다. TLE, WA 한 번씩 받고 고민만 하다 끝남.
총평
이전 콘테스트에 이어 또 다시 Div 숫자보다 적은 AC를 받았다. 배치 보정이 끝나서 레이팅이 하락했다.. Gray -> Gray ㅠ
728x90
반응형
'Problem Solving > Codeforces' 카테고리의 다른 글
[코드포스 / Codeforces] Round #899 (Div. 2) (0) | 2023.10.06 |
---|---|
[코드포스 / Codeforces] Educational Round #155 (Div. 2) (3) | 2023.10.05 |
[코드포스 / Codeforces] Round #894 (Div. 3) (2) | 2023.10.03 |
[코드포스 / Codeforces] Round #886 (Div. 4) (2) | 2023.10.02 |
[코드포스 / Codeforces] Round #897 (Div. 2) (1) | 2023.09.13 |