結果

問題 No.365 ジェンガソート
ユーザー mannshi222mannshi222
提出日時 2019-07-14 19:42:03
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 1,308 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 30,080 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-03 13:48:47
合計ジャッジ時間 4,108 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

#define ENDD '\0'
#define KIGY '\n'

#define TRUE 0
#define FALSE 1

int main()
{
        int ch;
        char buff[100000+1];
        int buffi;
        int N;
        int jen[100000+1];

        buffi = 0;
        while( (ch=getc(stdin)) != KIGY) {
                buff[buffi++] = ch;
        }
        buff[buffi] = ENDD;
        N = atoi(buff);


        buffi=0;
        int count = 1;
        while( (ch=getc(stdin)) != EOF) {
                        if( ch==' ' ||  ch==KIGY   ) {
                                buff[buffi] = ENDD;
                                jen[atoi(buff)] = count++;
                                buffi = 0;
                        }
                        else {
                                buff[buffi++] = ch;
                        }
        }

        count = 0;
        for( int i = N; i >=2; i-- ) {
                if( jen[i] > jen[i-1] ) {
                        continue;
                }

                count++;
                for( int j = 1; j <= N; j++ ) {
                        if( jen[i-1] > jen[j] ) {
                                jen[j]++;
                        }
                }
                jen[i-1] = 1;
        }

        /* search max */
        printf("%d\n", count );

        return 0;
}
0