結果

問題 No.365 ジェンガソート
ユーザー cielciel
提出日時 2016-04-29 23:21:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 33,860 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 05:55:20
合計ジャッジ時間 1,662 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 0 ms
6,940 KB
testcase_04 AC 0 ms
6,944 KB
testcase_05 AC 0 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 0 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 11 ms
6,940 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 11 ms
6,944 KB
testcase_37 AC 12 ms
6,940 KB
testcase_38 WA -
testcase_39 AC 14 ms
6,940 KB
testcase_40 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |         for(i=0,scanf("%d",&n);i<n;i++)scanf("%d",x+i);
      |                 ~~~~~^~~~~~~~~
main.cpp:37:45: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |         for(i=0,scanf("%d",&n);i<n;i++)scanf("%d",x+i);
      |                                        ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <algorithm>
#include <cstdio>
int x[100001],d[100001],c[100001];

int lis(int n){
	int i,j,I;
/*
	for(i=-1;I=0,++i<n;d[i]=I+1)
		for(j=i-1;~j;j--)
			if(x[j]<x[i]&&I<d[j])I=d[j];
*/
	// http://stackoverflow.com/questions/6129682/longest-increasing-subsequenceonlogn
	int sz = 1;
	c[1] = x[0];
	d[0] = 1;
	for(i=0;++i<n;){
		if(x[i] < c[1]){
			c[1] = x[i];
			d[i] = 1;
		}else if(x[i] > c[sz]){
			c[sz+1] = x[i];
			d[i] = sz+1;
			sz++;
		}else{
			int k = std::lower_bound(c,c+sz,x[i])-c;
			c[k] = x[i];
			d[i] = k;
		}
	}
	for(i=j=0;i<n;i++)
		if(d[i]>d[j])j=i;
	return d[j];
}

int n,i,T;
int main(){
	for(i=0,scanf("%d",&n);i<n;i++)scanf("%d",x+i);
	printf("%d\n",n-lis(n));
}
0