結果

問題 No.2742 Car Flow
ユーザー PechiPechi
提出日時 2024-04-21 00:16:01
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 2,295 bytes
コンパイル時間 1,924 ms
コンパイル使用メモリ 162,428 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 00:16:05
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
5,248 KB
testcase_01 AC 32 ms
5,376 KB
testcase_02 AC 32 ms
5,376 KB
testcase_03 AC 30 ms
5,376 KB
testcase_04 AC 31 ms
5,376 KB
testcase_05 AC 32 ms
5,376 KB
testcase_06 AC 30 ms
5,376 KB
testcase_07 AC 31 ms
5,376 KB
testcase_08 AC 30 ms
5,376 KB
testcase_09 AC 30 ms
5,376 KB
testcase_10 AC 23 ms
5,376 KB
testcase_11 AC 24 ms
5,376 KB
testcase_12 AC 20 ms
5,376 KB
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 14 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 30 ms
5,376 KB
testcase_17 AC 30 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 29 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 25 ms
5,376 KB
testcase_23 AC 30 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 27 ms
5,376 KB
testcase_26 AC 33 ms
5,376 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 13 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 25 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 27 ms
5,376 KB
testcase_33 AC 27 ms
5,376 KB
testcase_34 AC 13 ms
5,376 KB
testcase_35 AC 8 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 10 ms
5,376 KB
testcase_38 AC 25 ms
5,376 KB
testcase_39 AC 5 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<unordered_set>
#include<random>
#include <array>
#include <complex>
#include<chrono>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define LP(I,S,G) for (long long int I = (S); I < (G); ++I)
#define IN(X) 	for (int in = 0; in < X.size(); in++)cin >> X[in]
#define OUT(X) 	for (int in = 0; in < X.size(); in++)cout << X[in]<<" "
#define SORT(X) sort((X).begin(), (X).end())
#define CSORT(X,Y) sort(X.begin(), X.end(),Y)
#define COPY(X,Y) copy(X.begin(), X.end(), Y.begin())
#define ALL(X,Y) for (auto &(X) :(Y))
#define FULL(a)  (a).begin(),(a).end()
#define BFS(Q,S) for(Q.push(S);Q.size()!=0;Q.pop())
typedef long long int ll;
typedef unsigned long long int ull;
long long int M = 998244353;

chrono::system_clock::time_point starttime;
using namespace std::chrono;

inline float getTime() {
	return duration_cast<milliseconds>(system_clock::now() - starttime).count();
}


int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };

ll MAX(ll A, ll B) { return ((A) > (B) ? (A) : (B)); }
ll MIN(ll A, ll B) { return ((A) < (B) ? (A) : (B)); }
inline long long int xor128() {
	static long long int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	long long int t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

struct HashPair {

	//注意 constがいる
	template<class T1, class T2>
	size_t operator()(const pair<T1, T2> &p) const {

		//first分をハッシュ化する
		auto hash1 = hash<T1>{}(p.first);

		//second分をハッシュ化する
		auto hash2 = hash<T2>{}(p.second);

		//重複しないようにハッシュ処理
		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	IN(a);
	ll ans = 0;
	LP(i, 0, n)ans += a[i];
	if (ans > n / 2)ans = n - ans;
	cout << (ans*modinv(n, M)) % M;
	return 0;
}
0