結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー s1905oss1905os
提出日時 2021-03-31 22:25:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 506 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 31,816 KB
実行使用メモリ 4,536 KB
最終ジャッジ日時 2023-08-22 02:42:22
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 13 ms
4,536 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 506 ms
4,380 KB
testcase_08 AC 11 ms
4,424 KB
testcase_09 AC 11 ms
4,384 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

long min(long n, long a[], long memo[]){
	long i;
	long long shou = 10000000;
	long temp = -1;
	for(i=0;i<n;i++){
		if(memo[i] != -1) continue;
		if(shou > a[i]){
			shou = a[i];
			temp = i;
		}
	}
	if(temp != -1) memo[temp] = a[temp];
	return shou;
}

int main(void){
	long n,m,x,y;
	long a[100000];
	long i,memo[100000];
	long long sum = 0;
	scanf("%ld%ld%ld%ld",&n,&m,&x,&y);
	long count = n;
	for(i=0;i<n;i++){
		scanf("%ld",&a[i]);
		memo[i] = -1;
		if(a[i] <= y){
			count--;
			memo[i] = a[i];
			continue;
		}
		if(a[i] >= x) memo[i] = a[i];
		sum += a[i];
	}
	while(m < count){
		long long temp = min(n,a,memo);
		if(temp == 10000000){
			printf("Handicapped\n");
			return 0;
		}
		sum -= temp;
		count--;
		//printf("%d:sum=%d ",temp,sum);
	}
	printf("%lld\n",sum);
	return 0;
}
0