結果

問題 No.59 鉄道の旅
ユーザー cielciel
提出日時 2015-04-24 04:43:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 267 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 44,512 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 05:38:54
合計ジャッジ時間 1,279 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 75 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 10 ms
4,376 KB
testcase_13 AC 16 ms
4,380 KB
testcase_14 AC 17 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
 #import<deque>
  ^~~~~~
main.cpp:2:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
 #import<cstdio>
  ^~~~~~
main.cpp:3:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
 main(){std::deque<int>v;int N,K,n;scanf("%d%d",&N,&K);for(;N--;){scanf("%d",&n);auto it=std::lower_bound(v.begin(),v.end(),n>0?n:-n);if(n>0&&v.end()-it<K)v.insert(it,n);if(n<0&&it!=v.end()&&*it==-n)v.erase(it);}printf("%d\n",v.size());}
      ^

ソースコード

diff #

#import<deque>
#import<cstdio>
main(){std::deque<int>v;int N,K,n;scanf("%d%d",&N,&K);for(;N--;){scanf("%d",&n);auto it=std::lower_bound(v.begin(),v.end(),n>0?n:-n);if(n>0&&v.end()-it<K)v.insert(it,n);if(n<0&&it!=v.end()&&*it==-n)v.erase(it);}printf("%d\n",v.size());}
0