結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー kotatsugamekotatsugame
提出日時 2021-03-31 21:04:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 75,232 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 19:08:24
合計ジャッジ時間 1,645 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 30 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 25 ms
4,376 KB
testcase_08 AC 25 ms
4,376 KB
testcase_09 AC 24 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,M,X,Y;
main()
{
	cin>>N>>M>>X>>Y;
	long ans=0;
	vector<int>T;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		if(A>=X)
		{
			ans+=A;
			M--;
		}
		else if(A>Y)T.push_back(A);
	}
	if(M<0)cout<<"Handicapped"<<endl;
	else
	{
		sort(T.begin(),T.end());
		reverse(T.begin(),T.end());
		for(int i=0;i<T.size()&&i<M;i++)ans+=T[i];
		cout<<ans<<endl;
	}
}
0