結果

問題 No.1285 ゴミ捨て
ユーザー horiesiniti
提出日時 2023-02-15 00:28:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 75,100 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-07-17 11:57:11
合計ジャッジ時間 3,669 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
using namespace std;

map<int,int> ms,ms2;


int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		ms[a]++;
		ms2[a]++;
	}
	map<int,int>::iterator it,it2;
	for(map<int,int>::iterator it=ms.begin();it!=ms.end();it++){
		int s,c;
		s=(*it).first+1;
		it2=ms2.upper_bound(s);
		if(it2!=ms2.end()){
			(*it2).second--;
			if((*it2).second<=0){
				ms2.erase(it2);
			}
			n--;
		}
	}
	cout<<n<<endl;
	return 0;
}
0