Skip to content

Commit

Permalink
Add 01173.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Jan 7, 2024
1 parent 1d063c7 commit 6e77c66
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 01xxx/01173.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;

int solve(void) {
int N, m, M, T, R; cin >> N >> m >> M >> T >> R;
if (m + T > M) return -1;

int ans = 0, cur = m;
while (N > 0) {
if (cur + T <= M) {
cur += T;
N--;
} else {
cur -= R;
if (cur < m) cur = m;
}
ans++;
}
return ans;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);

cout << solve();
return 0;
}

0 comments on commit 6e77c66

Please sign in to comment.