結果
問題 | No.59 鉄道の旅 |
ユーザー |
|
提出日時 | 2015-04-24 04:40:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 450 ms / 5,000 ms |
コード長 | 302 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 38,528 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 20:36:59 |
合計ジャッジ時間 | 1,707 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=] 13 | printf("%d\n",v.size()); | ~^ ~~~~~~~~ | | | | int std::vector<int>::size_type {aka long unsigned int} | %ld main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d%d",&N,&K); | ~~~~~^~~~~~~~~~~~~~ main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include <vector>#include <cstdio>int main(){std::vector<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());}