結果
| 問題 | No.59 鉄道の旅 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2015-04-24 03:54:59 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 343 bytes | 
| コンパイル時間 | 347 ms | 
| コンパイル使用メモリ | 38,656 KB | 
| 実行使用メモリ | 9,600 KB | 
| 最終ジャッジ日時 | 2024-12-24 20:36:37 | 
| 合計ジャッジ時間 | 20,154 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 9 TLE * 3 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::multiset<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   18 |         printf("%d\n",se.size());
      |                 ~^    ~~~~~~~~~
      |                  |           |
      |                  int         std::multiset<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:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~
            
            ソースコード
#include <set>
#include <cstdio>
int main(){
	std::multiset<int>se;
	int N,K;
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
		int n;
		scanf("%d",&n);
		if(n>0){
			auto it=se.lower_bound(n);
			if(std::distance(it,se.end())<K)se.insert(n);
		}else{
			auto it=se.lower_bound(-n);
			if(*it==-n)se.erase(it);
		}
	}
	printf("%d\n",se.size());
}
            
            
            
        