結果
| 問題 | No.365 ジェンガソート |
| コンテスト | |
| ユーザー |
tsubaki961
|
| 提出日時 | 2016-04-29 23:44:51 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 750 bytes |
| 記録 | |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 41,408 KB |
| 実行使用メモリ | 11,424 KB |
| 最終ジャッジ日時 | 2026-04-20 13:09:30 |
| 合計ジャッジ時間 | 4,112 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 RE * 1 TLE * 1 -- * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:29:24: warning: 't' may be used uninitialized [-Wmaybe-uninitialized]
29 | a[t]=a[t-1];
| ^
main.cpp:5:21: note: 't' was declared here
5 | int b,i,cnt=0,s,t,j=0;
| ^
ソースコード
#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;
}
tsubaki961