結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2018-03-26 14:48:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,502 bytes |
コンパイル時間 | 4,484 ms |
コンパイル使用メモリ | 165,572 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 06:46:06 |
合計ジャッジ時間 | 5,278 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <cstdlib>#include <iostream>#include <cstdint>#include <vector>#include <string>#include <complex>#include <bitset>#include <queue>#include <stack>#include <utility>#include <unordered_set>#include <unordered_map>#include <boost/lexical_cast.hpp>#include <boost/algorithm/string/predicate.hpp>#include <boost/multi_array.hpp>using namespace std;#if 0// memoabs()start_with(str, "hoge");ends_with(str, "hoge");std::sort(d.begin(), d.end());d.erase(std::unique(d.begin(), d.end()), d.end());#endifusing namespace boost;using namespace boost::algorithm;static inline bool isOdd(int v){return v & 0x01;}int main(){int N;cin >> N;std::vector<int> A;std::vector<int> B;for (size_t i = 0; i < N; ++i) {int v;cin >> v;A.push_back(v);}for (size_t i = 0; i < N; ++i) {int v;cin >> v;B.push_back(v);}size_t win = 0;size_t not_win = 0;std::sort(B.begin(), B.end());std::sort(A.begin(), A.end());do {size_t w = 0;size_t nw = 0;for (size_t i = 0; i < N; ++i) {if (A[i] > B[i]) {w++;}else {nw++;}}if (w > nw) {win++;}else {not_win++;}} while (std::next_permutation(B.begin(), B.end()));cout << (double)win / (win+not_win) << endl;return 0;}