結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2021-03-20 09:39:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,207 bytes |
コンパイル時間 | 3,903 ms |
コンパイル使用メモリ | 251,152 KB |
最終ジャッジ日時 | 2025-01-19 20:08:27 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using namespace std;#define rep(i,a,b) for(int i = a; i < b; i++)#define rrep(i,a,b) for(int i = a; i >= b; i--)#define fore(i,a) for(auto& i : a)#define sz(x) (int)(x).size()using ll = long long;using pint = pair<int, int>;using pll = pair<long long, long long>;int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1};const int IINF = INT_MAX;const long long LINF = 1LL << 60;template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }int main() {cout << setprecision(15) << fixed;int N; cin >> N;vector<int> A(N);vector<int> B(N);rep(i, 0, N) cin >> A[i];rep(i, 0, N) cin >> B[i];vector<int> ord(N);iota(ord.begin(), ord.end(), 0);int all = 0;int win = 0;do {++all;int a = 0;rep(i, 0, N) {if (A[ord[i]] > B[i]) ++a;if (A[ord[i]] < B[i]) --a;}if (a > 0) win++;} while(next_permutation(ord.begin(), ord.end()));cout << (double)win / all << endl;return 0;}