結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  mannshi222 | 
| 提出日時 | 2019-07-14 19:50:26 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 2,000 ms | 
| コード長 | 1,172 bytes | 
| コンパイル時間 | 493 ms | 
| コンパイル使用メモリ | 29,824 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-24 14:30:58 | 
| 合計ジャッジ時間 | 1,890 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 41 | 
ソースコード
#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;
        int min = 1;
        for( int i = N; i >=2; i-- ) {
                if( jen[i] > jen[i-1] ) {
                        continue;
                }
                count++;
                jen[i-1] = min-1;
                min--;
        }
        /* search max */
        printf("%d\n", count );
        return 0;
}
            
            
            
        