Submission #3008777
Source Code Expand
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;
struct UnionFind {
vector<int> data;
UnionFind(int size) : data(size, -1) {}
void unionSet(int x, int y) {
x = root(x), y = root(y);
if (x != y) {
if (data[y] < data[x])swap(x, y);
data[x] += data[y]; data[y] = x;
}
}
bool findSet(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
};
int gcd(int a, int b) {
if (a < b)swap(a, b);
int k = a % b;
if (k == 1)return 1;
if (k == 0)return b;
int ans = gcd(b, k);
return ans;
}
int digisum(ll a) {
int sum = 0;
while (a) {
sum += a % 10;
a /= 10;
}
return sum;
}
int a[114514][3];
int main() {
int n;
cin >> n;
int c[514], s[514], f[514];
REP(i, n - 1)cin >> c[i] >> s[i] >> f[i];
REP(i, n - 1) {
int t = s[i] + c[i];
FOR(j, i + 1, n - 1) {
if (t <= s[j]) t = s[j] + c[j];
else {
t = ceil((double)t / (double)f[j]) * f[j] + c[j];
}
}
cout << t << endl;
}
cout << 0 << endl;
}
Submission Info
Submission Time |
|
Task |
C - Special Trains |
User |
jgvt5ti |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1864 Byte |
Status |
AC |
Exec Time |
4 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
4 ms |
256 KB |
02.txt |
AC |
4 ms |
256 KB |
03.txt |
AC |
4 ms |
256 KB |
04.txt |
AC |
4 ms |
256 KB |
05.txt |
AC |
4 ms |
256 KB |
06.txt |
AC |
3 ms |
256 KB |
07.txt |
AC |
4 ms |
256 KB |
08.txt |
AC |
4 ms |
256 KB |
09.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
2 ms |
256 KB |
11.txt |
AC |
3 ms |
256 KB |
12.txt |
AC |
2 ms |
256 KB |
sample_01.txt |
AC |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
sample_03.txt |
AC |
1 ms |
256 KB |