結果

問題 No.411 昇順昇順ソート
ユーザー tkw_techtkw_tech
提出日時 2016-08-12 23:31:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 1,366 ms
コンパイル使用メモリ 144,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 11:58:57
合計ジャッジ時間 2,510 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

int N , K;
ll C[40][40];

ll gcnt = 1;

int main(){
    for(int i = 0; i <= 25; i ++) {
        C[i][0] = 1;
        for(int j = 1; j <= i; j ++) {
            C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
    
    cin >> N >> K;
    ll cnt = 0;

    // 前半の最大値がmaxi
    // 前半に使える数字は K ~ maxi
    FOR(maxi,1,N+1) {
        if (K==maxi){
            if (K==1) continue;
            else {
                cnt++;
                continue;
            }
        }
        // maxi-K-1 個の中からi個選ぶ
        REP(i,maxi-K) {
            if (1+1+i>=N) continue;
            if (K==1 && i == maxi-K-1) continue;
            cnt += C[maxi-K-1][i];
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}
0