Submission #397038

# Submission time Handle Problem Language Result Execution time Memory
397038 2021-05-01T08:11:37 Z tibinyte Cambridge (info1cup18_cambridge) C++14
0 / 100
1 ms 204 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <bitset>
#include <string>
#include <unordered_map>
#define mod 1000000007
using namespace std;
int main() {
	int n, q;
	cin >> n >> q;
	vector<pair<int, int>> a(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].first >> a[i].second;
	}
	while (q--) {
		int st, dr;
		cin >> st >> dr;
		vector<pair<int, int>> tibi(1);
		for (int i = st; i <= dr; ++i) {
			tibi.push_back(a[i]);
		}
		sort(tibi.begin() + 1, tibi.end());
		long long sum = 0;
		int m = tibi.size() - 1;
		bool ok = true;
		for (int i = 1; i <= m; ++i) {
			sum += tibi[i].first;
			if (sum >= tibi[i].second) {
				ok = false;
				break;
			}
		}
		cout << ok << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct