답안 #397039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397039 2021-05-01T08:20:38 Z tibinyte Cambridge (info1cup18_cambridge) C++14
55 / 100
2000 ms 4772 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].second >> a[i].first;
	}
	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].second;
			if (sum >= tibi[i].first) {
				ok = false;
				break;
			}
		}
		cout << ok << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 77 ms 2996 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 9 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 725 ms 848 KB Output is correct
4 Correct 1472 ms 1336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 77 ms 2996 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 9 ms 588 KB Output is correct
6 Correct 725 ms 848 KB Output is correct
7 Correct 1472 ms 1336 KB Output is correct
8 Execution timed out 2077 ms 4772 KB Time limit exceeded
9 Halted 0 ms 0 KB -