結果

問題 No.1630 Sorting Integers (Greater than K)
ユーザー mlasdf2mlasdf2
提出日時 2021-07-31 12:22:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,712 bytes
コンパイル時間 3,331 ms
コンパイル使用メモリ 230,820 KB
実行使用メモリ 235,176 KB
最終ジャッジ日時 2023-10-14 14:51:20
合計ジャッジ時間 7,571 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
164,296 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,352 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,356 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
typedef long long ll;
const long long INF = 1LL<<60;
const double PI = acos(-1.0);
/*const double PI = atan2(0.0,-1.0)*/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i,aa,n) for(ll i = aa; i <= (ll)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define v2d(val1,val2,ini) vector<vector<ll>>(val1,vector<ll>(val2,ini));
#define v3d(val1,val2,val3,ini) vector<vector<vector<ll>>>(val1,vector<vector<ll>>(val2,vector<ll>(val3,ini)));
#define v4d(val1,val2,val3,val4,ini) vector<vector<vector<vector<ll>>>>(val1,vector<vector<vector<ll>>>(val2,vector<<vector<ll>>(val3,vector<ll>(val4,ini))));
#define pqe priority_queue<ll>
#define pqeg priority_queue<ll,vector<ll>,greater<ll>>
#define lcin(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define eout(...) COU(__VA_ARGS__);
#define sout(...) SCOU(__VA_ARGS__);
#define scin(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define lb(aa,val) lower_bound(ALL(aa),val)
#define pb push_back
#define bpc __builtin_popcountll
ll kaijou(ll e){ll r=1;rep(i,e){r*=(i+1);}return r;}
bool kukan(ll t,ll a,ll b){
if(a<=t&&t<=b){
return true;
}else return false;
}

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}

void COU(){}
template <class Head,class... Tail>
void COU(Head&& head,Tail&&... tail){
    cout<<head<<endl;
    COU(move(tail)...);
}

void SCOU(){}
template <class Head,class... Tail>
void SCOU(Head&& head,Tail&&... tail){
    cout<<head<<" ";
    SCOU(move(tail)...);
}

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

using pii = pair<ll,ll>;
using v2 = vector<vector<ll>>;
using v1 = vector<ll>;
using v2p = vector<vector<pii>>;
using v1p = vector<pii>;
const ll mo=1000000007;
//const ll mo=998244353;


ll mod_pow(ll N,ll n){
if(n==0) return 1;
ll hh;
hh=n%2;
int tt=mod_pow(N,n/2);
if(hh==0)return tt%mo*tt%mo;
else {return tt%mo*tt%mo*N%mo;}
}


int main(){

//cout<<fixed<<setprecision(15);
lcin(n);
string k;
cin>>k;
v1 aa(10,0);
rep1(i,1,9){
lcin(c);
aa[i]=c;
}

auto dfs = [&](auto self,ll ichi,ll e,v1 ff) -> string {
if(ichi==n)return "";
string st;
if(e){
string g="";
rep1(i,1,9){
rep(k,ff[i]){
g.pb(48+i);
}
}

return g;

}else{
rep1(i,k[ichi]-48,9){
if(ff[i]){
ff[i]--;
if(i==k[ichi]-48){
st=self(self,ichi+1,0,ff);
}else st=self(self,ichi+1,1,ff);
if(st!="a"){
char r=i+'0';
return r+st;
}
ff[i]++;
}
}
}


return "a";

    };

eout(dfs(dfs,0,0,aa));


}
0