結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
tsubaki961
|
| 提出日時 | 2016-04-30 00:13:39 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 560 bytes |
| コンパイル時間 | 524 ms |
| コンパイル使用メモリ | 21,248 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-10-04 23:24:11 |
| 合計ジャッジ時間 | 4,501 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 RE * 1 TLE * 1 -- * 35 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%ld",&i);
| ^~~~~~~~~~~~~~~
main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf(" %ld",&a[b]);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
int main()
{
long int b,i,cnt=0,s,t,j=0,x;
long int* a;
scanf("%ld",&i);
a=(long int*)malloc(sizeof(long int)*(i+1));
for(b=1;b<=i;b++){
scanf(" %ld",&a[b]);
}
do{
s=0;
for(b=1;b<i;b++){
for(x=b+1;x<=i;x++){
if(a[b]>a[x])goto loop;
}
if(b==i-1){
j=-1;
}
}
loop:
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++;
}
}while(j!=-1);
free(a);
printf("%ld",cnt);
return 0;
}
tsubaki961