Submission #862268

# Submission time Handle Problem Language Result Execution time Memory
862268 2023-10-17T21:41:48 Z TAhmed33 Osumnjičeni (COCI21_osumnjiceni) C++
0 / 110
1000 ms 8776 KB
#include <bits/stdc++.h>
using namespace std;
int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	pair <int, int> arr[n + 1];
	for (int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second;
	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		multiset <int> cur;
		vector <pair <int, int>> p;
		for (int i = l; i <= r; i++) {
			p.push_back(arr[i]);
		}
		sort(p.begin(), p.end());
		int ans = 0;
		for (auto [x, y] : p) {
			if (cur.empty()) {
				cur.insert(y);
				ans++;
				continue;
			}
			auto l = cur.begin();
			if (*l >= x) {
				cur.insert(y); ans++;
			} else {
				cur.erase(l); 
				cur.insert(y);
			}
		}
		cout << ans << '\n';
		assert(ans == cur.size());
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |   for (auto [x, y] : p) {
      |             ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from Main.cpp:1:
Main.cpp:37:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   assert(ans == cur.size());
      |          ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 8776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 8320 KB Output isn't correct
2 Halted 0 ms 0 KB -