結果

問題 No.139 交差点
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-23 09:48:46
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,120 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 24,200 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 21:35:07
合計ジャッジ時間 7,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,504 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 83 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 97 ms
4,380 KB
testcase_12 AC 19 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,376 KB
testcase_20 AC 0 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#define	NMAX	(100)
#define	RMAX	(100000)
#define TMAX	(20000000)

typedef struct{
	int w;
	int t;
}INTERSECTION;

INTERSECTION inter[NMAX+5];
int road[RMAX+5];

int main(void){
	int i,N,L;
	
	int step, npos=0;
	
	scanf("%d %d", &N, &L);
	for(i=1;i<=N;i++){
		int X,W,T;
		scanf("%d %d %d", &X, &W, &T);
		inter[i].w = W;
		inter[i].t = T;
		
		road[X] = i;
	}
	
	for(step=1 ; step < TMAX; step++){
		
		
		if(road[npos+1] == 0){
			npos += 1;
//			printf("%d %d\n", step, npos);
		}else{
			// 現在の時間+交差点の時間*2
			int nroad = road[npos+1];
			int nowSignal = step%(inter[nroad].t*2);
			if(nowSignal < inter[nroad].t){
				int tf=1;
				for(i=0;i<inter[nroad].w;i++){
					int ts = (step+i)%(inter[nroad].t*2);
					if(ts < inter[nroad].t){
					}else{
						tf=0;
					}
//					printf(" In Blue %d %d %d %d\n", ts, step,i, inter[nroad].t*2);
				}
				
				if(tf==1){
					npos+=1;
				}
				
//				printf("blue %d %d %d\n", step, npos,L);
			}else{
//				printf("Red  %d %d %d\n", step, npos,L);
			}
		}
		if(npos == L){
			printf("%d\n", step);
			break;
		}
	}
	
	return 0;
}
0