답안 #119064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119064 2019-06-20T08:54:37 Z Bruteforceman Cambridge (info1cup18_cambridge) C++11
55 / 100
2000 ms 4960 KB
#include "bits/stdc++.h"
using namespace std;
typedef pair <int, int> pii;
int t[100010], d[100010];

int query(int x, int y) {
	vector <pii> v;
	for(int i = x; i <= y; i++) {
		v.emplace_back(d[i], t[i]);
	}
	sort(v.begin(), v.end());
	long long sum = 0;
	for(int i = 0; i < v.size(); i++) {
		sum += v[i].second;
		if(sum >= v[i].first) {
			return false;
		}
	}
	return true;
}

int main(int argc, char const *argv[])
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%d %d", &t[i], &d[i]);
	}
	while(m--) {
		int p, q;
		scanf("%d %d", &p, &q);
		printf("%d\n", query(p, q));
	}
	return 0;
}

Compilation message

cambridge.cpp: In function 'int query(int, int)':
cambridge.cpp:13:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < v.size(); i++) {
                 ~~^~~~~~~~~~
cambridge.cpp: In function 'int main(int, const char**)':
cambridge.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
cambridge.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &t[i], &d[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
cambridge.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &p, &q);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 29 ms 3192 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 545 ms 940 KB Output is correct
4 Correct 1113 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 29 ms 3192 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
6 Correct 545 ms 940 KB Output is correct
7 Correct 1113 ms 1668 KB Output is correct
8 Execution timed out 2045 ms 4960 KB Time limit exceeded
9 Halted 0 ms 0 KB -