結果

問題 No.9 モンスターのレベル上げ
コンテスト
ユーザー hint908
提出日時 2024-09-20 17:04:59
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 585 ms / 5,000 ms
コード長 1,836 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,478 ms
コンパイル使用メモリ 209,896 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-23 12:14:50
合計ジャッジ時間 8,823 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:52:21: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   52 |                 auto[p,q] = *s.begin();
      |                     ^
main.cpp:59:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   59 |         for(auto[x,y]:s) chmax(a, y);
      |                 ^

ソースコード

diff #
raw source code

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


#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using VVVV = VV<VV<T>>;
#define rep(i,n) for(ll i=0ll;(i)<(n);(i)++)
#define REP(i,a,n) for(ll i=(a);(i)<(n);(i)++)
const long long INF = (1LL << 60);
const long long mod99 = 998244353;
const long long mod107 = 1000000007;
const long long mod = mod99;
#define eb emplace_back
#define be(v) (v).begin(),(v).end()
#define all(i,v) for(auto& (i) : (v))
#define UQ(v) sort(be(v)), (v).erase(unique(be(v)), (v).end())
#define LB(x,v) (lower_bound(be(v),(x))-(v).begin())
#define UB(x,v) (upper_bound(be(v),(x))-(v).begin())
#define dout()  cout << fixed << setprecision(20)
#define randinit() srand((unsigned)time(NULL))

template<class T, class U> bool chmin(T& t, const U& u) { if (t > u){ t = u; return 1;} return 0; }
template<class T, class U> bool chmax(T& t, const U& u) { if (t < u){ t = u; return 1;} return 0; }


ll Rnd(ll L=0, ll R=mod99){return rand()%(R-L)+L;}


void solve(){
    ll n;
    cin >> n;
    multiset<pair<ll,ll>> st;
    rep(i,n){
    	ll x;
    	cin >> x;
    	st.insert({x, 0});
    }
    V<ll> w(n);
    rep(i,n) cin >> w[i];
    ll ans = INF;
    rep(i, n){
    	auto s = st;
    	rep(j, n){
    		auto[p,q] = *s.begin();
    		s.erase(s.begin());
    		q++;
    		p += w[(i+j)%n]/2;
    		s.insert({p, q});
    	}
    	ll a = 0;
    	for(auto[x,y]:s) chmax(a, y);
    	chmin(ans, a);
    	
    	
    }
    cout << ans << endl;
}





int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t=1;
    // cin >> t;
    rep(i,t) solve();
}
0