Submission #4040255


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


void solve(ll N, ll K, ll R) {
    ll maxr = (N-K)*(N-K+1) / 2;
    if (R > maxr) {
        cout << "No Luck" << endl;
        return;
    }

    vi a;
    a.reserve(N);

    rep(i,K) {
        a.pb(i);
    }
    int nxt = K, left = N-K;
    int gain = 1;

    ll rest = R;

    for (int i=K; i<N; ++i) {
        if (rest == 0) break;
        if (rest >= gain) {
            a.pb(i); --left;
            rest -= gain;
            ++gain;
        } else {
            int ins = rest;
            a.insert(a.begin()+ins, i);
            rest = 0; --left;
            break;
        }
    }

    vi ans(N);
    rep(i,left) ans[i] = 1+i;
    for(int i=0; i<N-left; ++i) {
        ans[left+i] = N-a[i];
    }
    rep(i,N){
        if (i > 0) putchar(' ');
        printf("%d", ans[i]);
    }
    printf("\n");
}

int main() {
    ll N,K,R; cin >> N >> K >> R;
    solve(N,K,R);
    return 0;
}

Submission Info

Submission Time
Task B - 大吉数列 (Array of Fortune)
User naoya_t
Language C++14 (GCC 5.4.1)
Score 600
Code Size 2443 Byte
Status
Exec Time 10 ms
Memory 1536 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 200 / 200 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sub1_in01.txt, sub1_in02.txt, sub1_in03.txt, sub1_in04.txt, sub1_in05.txt, sub1_in06.txt, sub1_in07.txt, sub1_in08.txt, sub1_in09.txt, sub1_in10.txt
Subtask2 400 / 400 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sub1_in01.txt, sub1_in02.txt, sub1_in03.txt, sub1_in04.txt, sub1_in05.txt, sub1_in06.txt, sub1_in07.txt, sub1_in08.txt, sub1_in09.txt, sub1_in10.txt, sub2_in01.txt, sub2_in02.txt, sub2_in03.txt, sub2_in04.txt, sub2_in05.txt, sub2_in06.txt, sub2_in07.txt, sub2_in08.txt, sub2_in09.txt, sub2_in10.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB
sub1_in01.txt 1 ms 256 KB
sub1_in02.txt 1 ms 256 KB
sub1_in03.txt 1 ms 256 KB
sub1_in04.txt 1 ms 256 KB
sub1_in05.txt 1 ms 256 KB
sub1_in06.txt 1 ms 256 KB
sub1_in07.txt 1 ms 256 KB
sub1_in08.txt 1 ms 256 KB
sub1_in09.txt 1 ms 256 KB
sub1_in10.txt 1 ms 256 KB
sub2_in01.txt 9 ms 1280 KB
sub2_in02.txt 10 ms 1408 KB
sub2_in03.txt 10 ms 1536 KB
sub2_in04.txt 10 ms 1536 KB
sub2_in05.txt 3 ms 384 KB
sub2_in06.txt 10 ms 1536 KB
sub2_in07.txt 10 ms 1536 KB
sub2_in08.txt 10 ms 1152 KB
sub2_in09.txt 10 ms 1536 KB
sub2_in10.txt 1 ms 256 KB