0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Atcoder解いてみた AtCoder Beginner Contest C - Understory

0
Posted at

AtCoder Beginner Contest C - Understory

問題はこちら

回答

#include <iostream>
#include <string>
#include <map>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <limits.h>
#include <bitset>
#include <list>
#include <set>
#include <numeric>

int Q;
std::multiset<int> M;

struct Query {
	int com;
	int h;
};

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	std::cin >> Q;

	int sum = 0;
	for (int i = 0; i < Q; i++) {
		Query query;

		std::cin >> query.com >> query.h;

		if (query.com == 1) {
			// hをカウント
			M.insert(query.h);
			std::cout << M.size() << std::endl;
		}
		else {
			// h以下を削除
			M.erase(M.begin(), M.upper_bound(query.h));
			std::cout << M.size() << std::endl;
		}
	}

	return 0;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?