Submission #1926566


Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (ll i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    ll N;
    ll C[510],S[510],F[510];
    ll ans=INF;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N-1)cin>>C[i]>>S[i]>>F[i];
    REP(i,N){
        ll T=S[i]+C[i];
        DEB(i)DEB(T)END
        for(int j=i+1;j<N-1;j++){
            //DEB(j)
            TF(T<=S[j])
            if(T<=S[j]){
                T=S[j]+C[j];
            }else{
                DEB(T-S[j])DEB(F[j])DEB(S[j])END
                    T=((T-S[j])/F[j]+((T-S[j])%F[j]==0?0:1))*F[j]+S[j]+C[j];
            }
            DEB(j)DEB(T)END
        }
        cout<<T<<endl;
    }
    return 0;
}






//https://youtu.be/m0uWO0ngzbs?t=14m14s

Submission Info

Submission Time
Task C - Special Trains
User Nafmo2
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1473 Byte
Status
Exec Time 4 ms
Memory 256 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 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 4 ms 256 KB
02.txt 4 ms 256 KB
03.txt 4 ms 256 KB
04.txt 4 ms 256 KB
05.txt 4 ms 256 KB
06.txt 4 ms 256 KB
07.txt 4 ms 256 KB
08.txt 4 ms 256 KB
09.txt 1 ms 256 KB
10.txt 2 ms 256 KB
11.txt 3 ms 256 KB
12.txt 1 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB