結果

問題 No.3084 ゲームブックにトライ!
ユーザー 1_no_se1_no_se
提出日時 2021-03-30 00:22:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 500 ms
コード長 827 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 104,704 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-19 22:28:14
合計ジャッジ時間 4,410 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
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 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 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,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,504 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 42 ms
4,380 KB
testcase_26 AC 37 ms
4,376 KB
testcase_27 AC 52 ms
4,376 KB
testcase_28 AC 21 ms
4,380 KB
testcase_29 AC 52 ms
4,376 KB
testcase_30 AC 51 ms
4,380 KB
testcase_31 AC 52 ms
4,376 KB
testcase_32 AC 45 ms
4,380 KB
testcase_33 AC 44 ms
4,376 KB
testcase_34 AC 34 ms
4,376 KB
testcase_35 AC 34 ms
4,376 KB
testcase_36 AC 26 ms
4,380 KB
testcase_37 AC 7 ms
4,380 KB
testcase_38 AC 47 ms
4,380 KB
testcase_39 AC 45 ms
4,376 KB
testcase_40 AC 26 ms
4,380 KB
testcase_41 AC 29 ms
4,376 KB
testcase_42 AC 35 ms
4,380 KB
testcase_43 AC 50 ms
4,380 KB
testcase_44 AC 50 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <random>
#include <cassert>

typedef long long ll;
using namespace std;

constexpr ll mod007 = 1000000007;
constexpr ll mod998 = 998244353;

ll N, A[100000], res;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] %= mod998;
	}
	sort(A, A + N);

	for (int i = 0; i < N; i++) {
		res += A[i] * (N - 1);
		int l = i;
		int r = N;
		while (l + 1 != r) {
			int m = (l + r) / 2;
			if (A[i] + A[m] < mod998) {
				l = m;
			}
			else {
				r = m;
			}
		}
		res -= mod998 * (N - r);
	}
	cout << res << endl;
}
0