結果

問題 No.893 お客様を誘導せよ
ユーザー junsuijunsui
提出日時 2019-09-29 15:41:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 43,776 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 07:15:34
合計ジャッジ時間 1,342 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 11 ms
6,940 KB
testcase_04 AC 11 ms
6,940 KB
testcase_05 AC 11 ms
6,944 KB
testcase_06 AC 8 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 23 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <queue>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)

int main( void ){
	int n;
	if (!scanf( "%d", &n ))
		return 0;
	int* * array_ptr = new int*[n];
	int* counters = new int[n*2];

	rep( i, 0, n ){
		int num;
		if (!scanf( "%d", &num ))
			return 0;
		array_ptr[i] = new int[num];
		rep(j,0,num){
			if (!scanf( "%d", array_ptr[i]+j ))
				return 0;
		}
		counters[2*i] = 0;
		counters[2*i+1] = num;
	}
	bool is_finished = false;
	std::queue<int> costomers;
	while(!is_finished){
		is_finished = true;
		rep(i,0,n){
			if (counters[2*i] != counters[2*i+1]){
				is_finished = false;
				costomers.push(array_ptr[i][counters[2*i]]);
				counters[2*i]++;
			}
		}
	}
	while(!costomers.empty()){
		printf("%d ", costomers.front());
		costomers.pop();
	}
	printf("\n");
	return 0;
}
0