Submission #72383862


Source Code Expand

#if !__INCLUDE_LEVEL__
#include __FILE__

void solve() {
  int N,X;
  ll K;
  cin>>N>>K>>X;
  vl A(N);
  rep(i,N)cin>>A[i];
  sort(rall(A));
  priority_queue<pair<ll,vector<int>>> pq;
  set<vi> st;
  { 
    vi B(N,0);
    B[0]=K;
    pq.push({K*A[0],B});
    st.insert(B);
  }
  while(X--){
    auto [val,C]=pq.top();
    
    pq.pop();
    cout<<val<<el;
    rep(i,N-1){
      if(C[i]>0){
        C[i]--;
        C[i+1]++;
        val-=A[i];
        val+=A[i+1];
        if(!st.count(C)){pq.push({val,C});st.insert(C);}
        val-=A[i+1];
        val+=A[i];
        C[i+1]--;
        C[i]++;
      }
    }
  }
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

#else
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint=modint998244353;
//using mint=modint1000000007;
  
// 関数テンプレート
template<typename T> bool chmax(T &m, const T q) {
    if (m < q) {m = q; return true;} else return false; }

template<typename T> bool chmin(T &m,const T q){
    if(m>q){m=q;return true;}else return false;
}
template<typename T>
bool grid_inside(const T h, const T w, const T &m, const T &n) {
    return (m >= 0 && m < h && n >= 0 && n < w);
}
// ループマクロ
#define rep(i,r) for(int i=0;(r)>i;i++)
#define REP(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,N) for(int i=(N)-1;i>=0;i--)
#define RREP(i,r,N) for(int i=(N)-1;i>=r;i--)

// コンテナショートカット
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define pb push_back
#define fixed15 std::fixed << std::setprecision(15)
// YES/NO 出力
#define Yes cout<<"Yes"<<el
#define No cout<<"No"<<el
#define YES cout<<"YES"<<el
#define NO cout<<"NO"<<el
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

// 型エイリアス
using ll=long long;
using ull=unsigned long long;
using pqgi=priority_queue<int, vector<int>, greater<int>>;
using pqgl=priority_queue<long long, vector<long long>, greater<long long>>;
using pqgpl=priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>>;
using pqgptpl=priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>>;
using pqi=priority_queue<int>;
using pii=pair<int, int>;
using tpi=tuple<int,int,int>;
using tpl=tuple<ll,ll,ll>;
using pll=pair<long long, long long>;
using vs=vector<string>;
using vi=vector<int>;
using vb=vector<bool>;
using vl=vector<long long>;
using vc=vector<char>;
using vvi=vector<vector<int>>;
using vvl=vector<vector<long long>>;
using vvc=vector<vector<char>>;
using vvb=vector<vector<bool>>;
using vvs=vector<vector<string>>;
using vpii=vector<pii>;
using vpll=vector<pll>;
using vvpii=vector<vector<pii>>;
using vvpll=vector<vector<pll>>;
using vtiii=vector<tuple<int, int, int>>;
using lb=long double;

// 定数
const long long INF=1e18;
const int mod=1e9+7;
//const int mod=998244353;
const int MAX=1e5+10;
const int MIN=-1e9;
const vpii dir={{1,0},{-1,0},{0,1},{0,-1}};
#endif


Submission Info

Submission Time
Task E - Cookies
User yasaikeikaku
Language C++23 (GCC 15.2.0)
Score 450
Code Size 3380 Byte
Status AC
Exec Time 475 ms
Memory 76568 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 34
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 1 ms 3600 KiB
hand_02.txt AC 1 ms 3672 KiB
hand_03.txt AC 1 ms 3444 KiB
random_01.txt AC 60 ms 13036 KiB
random_02.txt AC 59 ms 13120 KiB
random_03.txt AC 412 ms 76496 KiB
random_04.txt AC 412 ms 76496 KiB
random_05.txt AC 412 ms 76472 KiB
random_06.txt AC 413 ms 76496 KiB
random_07.txt AC 1 ms 3608 KiB
random_08.txt AC 1 ms 3492 KiB
random_09.txt AC 411 ms 76536 KiB
random_10.txt AC 412 ms 76496 KiB
random_11.txt AC 410 ms 76568 KiB
random_12.txt AC 410 ms 76544 KiB
random_13.txt AC 193 ms 41220 KiB
random_14.txt AC 162 ms 25364 KiB
random_15.txt AC 475 ms 51684 KiB
random_16.txt AC 368 ms 38680 KiB
random_17.txt AC 231 ms 36476 KiB
random_18.txt AC 2 ms 3780 KiB
random_19.txt AC 382 ms 37948 KiB
random_20.txt AC 1 ms 3600 KiB
random_21.txt AC 194 ms 41216 KiB
random_22.txt AC 161 ms 25268 KiB
random_23.txt AC 421 ms 58728 KiB
random_24.txt AC 410 ms 50024 KiB
random_25.txt AC 110 ms 13488 KiB
random_26.txt AC 149 ms 16912 KiB
random_27.txt AC 182 ms 15484 KiB
random_28.txt AC 106 ms 12268 KiB
sample_01.txt AC 1 ms 3568 KiB
sample_02.txt AC 1 ms 3444 KiB
sample_03.txt AC 1 ms 3528 KiB