結果

問題 No.2028 Even Choice
ユーザー olpheolphe
提出日時 2022-08-05 21:42:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 133,228 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-13 22:19:08
合計ジャッジ時間 3,130 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 41 ms
4,352 KB
testcase_02 AC 40 ms
4,372 KB
testcase_03 AC 28 ms
4,356 KB
testcase_04 AC 28 ms
4,352 KB
testcase_05 AC 10 ms
4,352 KB
testcase_06 WA -
testcase_07 AC 12 ms
4,352 KB
testcase_08 AC 25 ms
4,348 KB
testcase_09 AC 30 ms
4,352 KB
testcase_10 AC 12 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 32 ms
4,348 KB
testcase_14 AC 12 ms
4,352 KB
testcase_15 AC 1 ms
4,356 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,356 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 2 ms
4,372 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 1 ms
4,372 KB
testcase_28 AC 16 ms
4,352 KB
testcase_29 AC 10 ms
4,348 KB
testcase_30 AC 8 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> M;
	vector<int>v(N);
	for (auto& i : v)cin >> i;
	if (M == 1) {
		int mx = 0;
		for (int i = 1; i < N; i += 2) {
			mx = max(mx, v[i]);
		}
		cout << mx << endl;
		return 0;
	}
	v.erase(v.begin());
	sort(v.rbegin(), v.rend());
	long long ans = 0;
	for(int i=0;i<M;i++){
		ans += v[i];
	}
	cout << ans << endl;
}
0