提出 #1030373


ソースコード 拡げる

#include <cstdio>
#include <vector>

int main(void){
	using namespace std;
	
	vector<int> waitList[5];
	
	int groups;
	scanf("%d", &groups);
	
	for(int i = 1; i <= groups; ++i){
		int n;
		scanf("%d", &n);
		waitList[n].push_back(i);
	}
	
	int ans = 0, space = 4;
	while(waitList[1].size() || waitList[2].size() || waitList[3].size() || waitList[4].size()){
		int next = 0;
		for(int i = 1; i <= 4; ++i) if(waitList[i].size() && (!next || waitList[next].begin() > waitList[i].begin())) next = i;
		
		space -= next;
		waitList[next].erase(waitList[next].begin());
		
		int asain = space;
		while(space > 0 && asain > 0){
			if(!waitList[asain].size()) {
				--asain;
			}else{
				space -= asain;
				waitList[asain].erase(waitList[asain].begin());
				asain = space;
			}
		}
		
		++ans;
		space = 4;
	}
	
	printf("%d\n", ans);
return 0;
}

提出情報

提出日時
問題 C - スキーリフトの相乗り
ユーザ katuh9
言語 C++14 (GCC 5.4.1)
得点 400
コード長 884 Byte
結果 AC
実行時間 181 ms
メモリ 896 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &groups);
                      ^
./Main.cpp:14:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^

ジャッジ結果

セット名 All
得点 / 配点 400 / 400
結果
AC × 49
セット名 テストケース
All 00_sample00, 00_sample01, 100_corner0000, 100_corner0001, 100_corner0002, 100_corner0003, 10_small-0000, 10_small-0001, 10_small-0002, 10_small-0003, 10_small-0004, 10_small-0005, 10_small-0006, 10_small-0007, 10_small-0008, 10_small-0009, 20_special-0000, 20_special-0001, 20_special-0002, 20_special-0003, 20_special-0004, 20_special-0005, 20_special-0006, 20_special-0007, 20_special-0008, 20_special-0009, 20_special-0010, 20_special-0011, 20_special-0012, 20_special-0013, 20_special-0014, 30_large-0000, 30_large-0001, 30_large-0002, 30_large-0003, 30_large-0004, 30_large-0005, 30_large-0006, 30_large-0007, 30_large-0008, 30_large-0009, 80_combination-type00, 80_combination-type01, 80_combination-type02, 80_combination-type03, 80_combination-type04, 80_combination-type05, 80_combination-type06, 90_tayama-killer00
ケース名 結果 実行時間 メモリ
00_sample00 AC 2 ms 256 KiB
00_sample01 AC 3 ms 256 KiB
100_corner0000 AC 2 ms 256 KiB
100_corner0001 AC 2 ms 256 KiB
100_corner0002 AC 2 ms 256 KiB
100_corner0003 AC 2 ms 256 KiB
10_small-0000 AC 3 ms 256 KiB
10_small-0001 AC 3 ms 256 KiB
10_small-0002 AC 2 ms 256 KiB
10_small-0003 AC 3 ms 256 KiB
10_small-0004 AC 2 ms 256 KiB
10_small-0005 AC 3 ms 256 KiB
10_small-0006 AC 3 ms 256 KiB
10_small-0007 AC 3 ms 384 KiB
10_small-0008 AC 2 ms 256 KiB
10_small-0009 AC 3 ms 256 KiB
20_special-0000 AC 2 ms 256 KiB
20_special-0001 AC 3 ms 256 KiB
20_special-0002 AC 2 ms 256 KiB
20_special-0003 AC 3 ms 256 KiB
20_special-0004 AC 2 ms 256 KiB
20_special-0005 AC 3 ms 256 KiB
20_special-0006 AC 2 ms 256 KiB
20_special-0007 AC 3 ms 256 KiB
20_special-0008 AC 2 ms 256 KiB
20_special-0009 AC 2 ms 256 KiB
20_special-0010 AC 3 ms 256 KiB
20_special-0011 AC 3 ms 256 KiB
20_special-0012 AC 2 ms 256 KiB
20_special-0013 AC 3 ms 256 KiB
20_special-0014 AC 3 ms 256 KiB
30_large-0000 AC 181 ms 896 KiB
30_large-0001 AC 181 ms 896 KiB
30_large-0002 AC 180 ms 768 KiB
30_large-0003 AC 180 ms 896 KiB
30_large-0004 AC 181 ms 896 KiB
30_large-0005 AC 180 ms 896 KiB
30_large-0006 AC 180 ms 896 KiB
30_large-0007 AC 180 ms 768 KiB
30_large-0008 AC 180 ms 768 KiB
30_large-0009 AC 180 ms 896 KiB
80_combination-type00 AC 3 ms 256 KiB
80_combination-type01 AC 2 ms 256 KiB
80_combination-type02 AC 3 ms 256 KiB
80_combination-type03 AC 2 ms 256 KiB
80_combination-type04 AC 3 ms 256 KiB
80_combination-type05 AC 2 ms 256 KiB
80_combination-type06 AC 3 ms 256 KiB
90_tayama-killer00 AC 3 ms 256 KiB