結果

問題 No.1590 Random Shopping
ユーザー 2 n2 n
提出日時 2021-07-08 23:24:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 5,891 bytes
コンパイル時間 4,567 ms
コンパイル使用メモリ 197,148 KB
実行使用メモリ 186,600 KB
最終ジャッジ日時 2023-09-14 05:39:02
合計ジャッジ時間 14,719 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 195 ms
13,284 KB
testcase_09 AC 3,126 ms
136,396 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:123: 警告: "dbg" が再定義されました
  123 | #define dbg(x) (x)
      | 
main.cpp:120: 備考: ここが以前の宣言がある位置です
  120 | #define dbg(x) (debug_h(__FILE__, __LINE__, "" #x),dbg_(x))
      | 
main.cpp:124: 警告: "debug" が再定義されました
  124 | #define debug(...) ((void)0)
      | 
main.cpp:117: 備考: ここが以前の宣言がある位置です
  117 | #define debug(...) (debug_h(__FILE__, __LINE__, "" #__VA_ARGS__),debug_(__VA_ARGS__))
      | 
main.cpp:126: 警告: "clk" が再定義されました
  126 | #define clk(...) ((void)0)
      | 
main.cpp:121: 備考: ここが以前の宣言がある位置です
  121 | #define clk(...) (cerr << __VA_ARGS__ " @ " << (clock()-clock0) <<endl,(void)0)
      | 

ソースコード

diff #

#pragma GCC target("avx2")
//#pragma GCC target("avx")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

// #include<bits/stdc++.h>

// #include <array>
#include <vector>
// #include <list>
// #include <forward_list>
#include <deque>
#include <queue>
#include <stack>

// #include <bitset>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>

#include <algorithm>

#include <string>
#include <iostream>
#include <iomanip>
// #include <sstream>

// #include <bit>
// #include <complex>
// #include <exception>
// #include <fstream>
// #include <functional>
// #include <iosfwd>
// #include <iterator>
// #include <limits>
// #include <locale>
// #include <memory>
// #include <new>
// #include <numeric>
// #include <stdexcept>
// #include <typeinfo>
// #include <utility>
// #include <valarray>
// #include <atomic>
// #include <chrono>
// #include <condition_variable>
// #include <future>
// #include <mutex>
// #include <random>
// #include <ratio>
// #include <regex>
// #include <scoped_allocator>
// #include <system_error>
// #include <thread>
// #include <tuple>
// #include <typeindex>
// #include <type_traits>

// #include <cctype>
// #include <cerrno>
// #include <cfloat>
// #include <ciso646>
// #include <climits>
// #include <clocale>
// #include <cmath>
// #include <csetjmp>
// #include <csignal>
// #include <cstdarg>
// #include <cstddef>
// #include <cstdio>
// #include <cstdlib>
// #include <cstring>
#include <ctime>
// #include <ccomplex>
// #include <cfenv>
// #include <cinttypes>
// #include <cstdbool>
// #include <cstdint>
// #include <ctgmath>
// #include <cwchar>
// #include <cwctype>

using namespace std;
#include <atcoder/all>
using namespace atcoder;

#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)

using ll = long long;
using ull = unsigned long long;
template<typename T> using maxque = priority_queue<T>;
template<typename T> using minque = priority_queue<T,vector<T>,greater<T>>;
#define int ll
#define endl "\n"
#define unless(cond) if(!(cond))
#define until(cond) while(!(cond))
#define rep(i,s,e) for(ll i = (s); i < (e); ++i)
#define repR(i,s,e) for(ll i = (e)-1; (s) <= i; --i)
#define repE(i,s,e) for(ll i = (s); i <= (e); ++i)
#define repER(i,s,e) for(ll i = (e); (s) <= i; --i)
#define repSubsetR(set,super) for(ll _super=super,set = _super; 0 <= set; --set)if(set &= _super, true)
#define ALL(xs) (xs).begin(), (xs).end()
#define ALLR(xs) (xs).rbegin(), (xs).rend()
#define ALLC(xs) (xs).cbegin(), (xs).cend()
#define ALLCR(xs) (xs).crbegin(), (xs).crend()
template<typename C> void uniq(C &xs){ xs.erase(unique(ALL(xs)), xs.end()); }
template<typename C> constexpr ll len(C &&xs){ return size(forward<C>(xs)); }
ll BIT(ll n){ return 1LL<<n; }

auto clock0 = clock();
void debug_h(const char *file, signed line, const char *str_args){ cerr << file << ":" << line << ":    " << str_args << "  =>  "; }
template<class X, class... Xs> void debug_(const X &x, const Xs&... xs){ cerr << x; (void)initializer_list<int>{ (cerr << ", " << xs,0)... };cerr << endl; }void debug_(){ cerr << endl; }
#define debug(...) (debug_h(__FILE__, __LINE__, "" #__VA_ARGS__),debug_(__VA_ARGS__))
#define ASSERT(pred,...) (static_cast<bool>(pred) ? void(0) : (debug_h(__FILE__, __LINE__, "ASSERT FAIL!   " #pred ";   " #__VA_ARGS__),debug_(__VA_ARGS__),exit(1)))
template<class X> X &&dbg_(X &&x){ cerr<<x<<endl; return forward<X>(x); }
#define dbg(x) (debug_h(__FILE__, __LINE__, "" #x),dbg_(x))
#define clk(...) (cerr << __VA_ARGS__ " @ " << (clock()-clock0) <<endl,(void)0)
#ifndef DEBUG
#define dbg(x) (x)
#define debug(...) ((void)0)
//#define ASSERT(pred,...) ((void)0)
#define clk(...) ((void)0)
#endif

template<class C> auto operator<<(ostream &os, const C &xs) -> enable_if_t<!is_same_v<typename iterator_traits<decltype(begin(xs))>::value_type,char>,ostream&> { os<<"[ "; for(auto&&x:xs)os<<x<<", "; return os<<"]"; }
template<typename MINT, typename = internal::is_modint_t<MINT>> ostream &operator<<(ostream &out, MINT x){ return out << x.val(); }

template<typename F> struct Fix : F {
    template<typename G> Fix(G &&g) : F{forward<G>(g)} {}
    template<typename... Xs> decltype(auto) operator()(Xs&&... xs)const{ return F::operator()(*this, forward<Xs>(xs)...); }
};
template<typename F> Fix(F&&) -> Fix<decay_t<F>>;

template<typename T,typename U> bool chmin(T &a, U b){ if(a <= b)return false; a = b; return true; }
template<typename T,typename U> bool chmax(T &a, U b){ if(a >= b)return false; a = b; return true; }

//const signed MOD = 998244353;
const signed MOD = 1000000007; // 10^9+7
using mint = static_modint<MOD>;
// using mint = dynamic_modint<-1>; // mint::set_mod(mod);
// using mint0 = dynamic_modint<0>; // mint0::set_mod(mod);

const ll INF = BIT(60);



double solve(){
    ll n;cin>>n;
    vector<signed> as(n);for(auto&a:as)cin>>a;
    vector<signed> rs(n);for(auto&r:rs)cin>>r;
    map<multiset<signed>,double> probs;
    probs[multiset<signed>()] = 1;
    double e=0;
    rep(i,0,n){
        debug(i,rs[i]);
        map<multiset<signed>,double> newprobs;
        for(auto const& pair : probs){
            auto rest = pair.first;
            auto p = pair.second;
            rest.insert(as[i]);
            newprobs[rest] += p / 2;
            auto it = rest.begin();
            e += p / 2 * rs[i] * *it;
            rest.erase(it);
            newprobs[rest] += p / 2;
        }
        debug(e);
        probs = move(newprobs);
    }
    return e;
}

signed main(){
    cin.tie(nullptr);ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    try{
        cout << solve() << endl;
        return 0;
    }catch(exception& e){
        cerr << e.what() << endl;
    }catch(char *s){
        cerr << s << endl;
    }
    return 1;
}
0