結果

問題 No.2742 Car Flow
ユーザー rii922rii922
提出日時 2024-04-21 15:50:35
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 2,819 bytes
コンパイル時間 3,775 ms
コンパイル使用メモリ 274,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:50:42
合計ジャッジ時間 5,711 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
5,248 KB
testcase_01 AC 14 ms
5,376 KB
testcase_02 AC 14 ms
5,376 KB
testcase_03 AC 14 ms
5,376 KB
testcase_04 AC 14 ms
5,376 KB
testcase_05 AC 14 ms
5,376 KB
testcase_06 AC 15 ms
5,376 KB
testcase_07 AC 14 ms
5,376 KB
testcase_08 AC 14 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
testcase_12 AC 9 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 14 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 14 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 11 ms
5,376 KB
testcase_23 AC 13 ms
5,376 KB
testcase_24 AC 8 ms
5,376 KB
testcase_25 AC 12 ms
5,376 KB
testcase_26 AC 14 ms
5,376 KB
testcase_27 AC 5 ms
5,376 KB
testcase_28 AC 7 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 12 ms
5,376 KB
testcase_31 AC 5 ms
5,376 KB
testcase_32 AC 14 ms
5,376 KB
testcase_33 AC 12 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
testcase_35 AC 5 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 5 ms
5,376 KB
testcase_38 AC 12 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 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 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmaxeq(T &a, const T &b) { if (a<=b) { a=b; return 1; } return 0; }
template<class T>bool chmineq(T &a, const T &b) { if (b<=a) { a=b; return 1; } return 0; }
bool yes(bool a) { cout << (a?"yes":"no") << endl; return a; }
bool Yes(bool a) { cout << (a?"Yes":"No") << endl; return a; }
bool YES(bool a) { cout << (a?"YES":"NO") << endl; return a; }
void _main();
int main() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); _main(); return 0; }

const int mod = 998244353;
struct mint {
	long long x;
	mint(long long x = 0) : x((x%mod+mod)%mod) {}
	mint operator-() const { return mint(-x); }
	mint &operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint &operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint &operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint &operator++() {
		*this += 1;
		return *this;
	}
	mint operator++(int) {
		mint temp = *this;
		++*this;
		return temp;
	}
	mint &operator--() {
		*this -= 1;
		return *this;
	}
	mint operator--(int) {
		mint temp = *this;
		--*this;
		return temp;
	}
	mint operator+(const mint a) { return mint(*this) += a; }
	mint operator-(const mint a) { return mint(*this) -= a; }
	mint operator*(const mint a) { return mint(*this) *= a; }
	mint pow(long long t) const {
		if (t < 0) return pow(-t).inv();
		if (t == 0) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const { return pow(mod - 2); }
	mint &operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) { return mint(*this) /= a; }
	friend istream &operator>>(istream &is, mint &a) {
		long long x;
		is >> x;
		a = mint(x);
		return is;
	}
	friend ostream &operator<<(ostream &os, const mint &a) {
		os << a.x;
		return os;
	}
};

void _main() {
	int N; cin >> N;
	int cnt = 0;
	rep(i, N) {
		int A; cin >> A;
		if (A == 0) cnt++;
	}
	cout << mint(min(cnt, N-cnt))/N << endl;
}
0