Skip to content

Commit

Permalink
ABC358B Ticket Counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Jun 17, 2024
1 parent 9dc9dec commit 7b7afd0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions atcoder/abc358b_ticket_counter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Vicfred
// https://atcoder.jp/contests/abc358/tasks/abc358_b
// implementation
#include <iostream>
#include <vector>

using namespace std;

int main() {
long long int N, A;
cin >> N >> A;
vector<long long int> T(N);
for(int i = 0; i < N; ++i) {
cin >> T[i];
}
cout << T[0] + A << endl;
int current = T[0] + A;
for(int i = 1; i < N; ++i) {
if(current <= T[i]) {
current = T[i] + A;
cout << current << endl;
} else {
current = T[i] + abs(T[i] - current) + A;
cout << current << endl;
}
}
return 0;
}

0 comments on commit 7b7afd0

Please sign in to comment.