Skip to content

Commit

Permalink
ABC378B Garbage Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Nov 11, 2024
1 parent 1853b35 commit 4c88ba5
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions atcoder/abc378b_garbage_collection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Vicfred
// https://atcoder.jp/contests/abc378/tasks/abc378_b
// math, implementation
#include <iostream>
#include <vector>

using namespace std;

int main() {
int N;
cin >> N;
vector<long long> r(N), q(N);
for(int i = 0; i < N; ++i) {
cin >> r[i] >> q[i];
}
int Q;
cin >> Q;
long long t, d;
for(int i = 0; i < Q; ++i) {
cin >> t >> d;
t -= 1;
int a = (d / r[t]) * r[t] + q[t];
/*
cout << "day " << d << endl;
cout << "r: " << r[t] << endl;
cout << "q: " << q[t] << endl;
cout << "a: " << a << endl;
*/
if(d <= a) {
cout << a << endl;
} else {
cout << a + r[t] << endl;
}
// cout << "======" << endl;
}
return 0;
}

0 comments on commit 4c88ba5

Please sign in to comment.