結果

問題 No.59 鉄道の旅
ユーザー startcppstartcpp
提出日時 2014-11-06 23:45:58
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 583 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 51,584 KB
実行使用メモリ 5,328 KB
最終ジャッジ日時 2023-08-26 05:22:23
合計ジャッジ時間 2,430 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 RE -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 180 ms
4,376 KB
testcase_09 AC 93 ms
4,376 KB
testcase_10 AC 104 ms
4,376 KB
testcase_11 AC 56 ms
4,376 KB
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//効率の悪い解法
#include<iostream>
using namespace std;

int n,k;
int w[10001];

int main(){
	int i,j;
	cin >> n >> k;
	for( i = 0; i < n; i++ ){
		int cnt = 0;
		cin >> w[i];
		if( w[i] > 0 ){
			for( j = 0; j < i; j++ ){
				if( w[j] >= w[i] )
					cnt++;
			}
			if( cnt >= k )
				w[i] = 0;
		}
		else{
			for( j = 0; j < i; j++ ){
				if( w[i] == -w[j] )
					break;
			}
			if( j < i ){
				w[j] = 0;
			}
			w[i] = 0;
		}
	}
	
	int ans = 0;
	for( i = 0; i < n; i++ ){
		if( w[i] )
			ans++;
	}
	cout << ans << endl;
	return 0;
}
0