結果

問題 No.365 ジェンガソート
ユーザー tsubaki961tsubaki961
提出日時 2016-04-29 23:44:51
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 750 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 24,576 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-15 06:08:59
合計ジャッジ時間 3,683 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
13,756 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%d\n",&i);
      |     ~~~~~^~~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf(" %d",&a[b]);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:29:24: warning: ‘t’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |                 a[t]=a[t-1];
      |                        ^

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int b,i,cnt=0,s,t,j=0;
    int* a;
    scanf("%d\n",&i);
    a=(int*)malloc(sizeof(int)*(i+1));
    for(b=1;b<=i;b++){
        scanf(" %d",&a[b]);
    }
    while(j!=-1){
        s=0;
        for(b=1;b<i;b++){
            if(a[b]>a[b+1]){
                break;
            }else if(b==(i-1)){
                j=-1;
            }
        }
        if(j!=-1){
            for(b=2;b<=i;b++){
                if(a[b]<=a[1]&&a[b]>=s){
                    s=a[b];
                    t=b;
                }
            }
            for(b=t;b>1;b--){
                a[t]=a[t-1];
            }
            a[1]=s;
            cnt++;
        }
    }
    free(a);
    printf("%d\n",cnt);
    return 0;
}
0