답안 #460834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
460834 2021-08-09T10:16:39 Z bigo Fountain (eJOI20_fountain) C++14
30 / 100
1155 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int main() {
	int n, q;
	cin >> n >> q;
	vector<pii>vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i].first >> vec[i].second;
	}
	vector<vector<int>>sed(n);
	for (int i = 0; i < n; i++) {
		sed[i].push_back(i+1);
		for (int j = i + 1; j < n; j++) {
			if (vec[sed[i][sed[i].size() - 1]-1].first < vec[j].first)
				sed[i].push_back(j+1);
		}
	}
	vector<int>ans1;
	while (q--) {
		int r, c;
		cin >> r >> c;
		vector<int>tmp = sed[r - 1];
		int ans = -1;
		for (int i = 0; i < tmp.size(); i++) {
			if ((c - vec[tmp[i]-1].second) > 0) {
				c -= vec[tmp[i]-1].second;
			}
			else {
				ans = tmp[i];
				break;
			}
		}
		if (ans == -1)
			ans = 0;
		ans1.push_back(ans);
	}
	for (int i = 0; i < ans1.size(); i++) {
		cout << ans1[i] << endl;
	}
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for (int i = 0; i < tmp.size(); i++) {
      |                   ~~^~~~~~~~~~~~
fountain.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for (int i = 0; i < ans1.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 436 KB Output is correct
5 Correct 14 ms 3020 KB Output is correct
6 Correct 9 ms 1320 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1155 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 436 KB Output is correct
5 Correct 14 ms 3020 KB Output is correct
6 Correct 9 ms 1320 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Runtime error 1155 ms 524292 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -