답안 #388745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388745 2021-04-12T19:43:39 Z Alexandra Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 5888 KB
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int N, Q;
bool romper;
int resp;

int a (vector <int>& litros, int r, int& v, vector<int>& d, vector<int>& c) {
	if (romper==true) {
		return resp;
	}

	for (int k=r; k<=N; k++) {
		if (romper==true) {
			if (resp==r) {
				resp = 0;
			}
			return resp;
			break;
		}

		else {

			if (litros[k]>c[k]) {

				if (k==N-1) {
					romper=true;
					return 0;
					break;
				}

				for (int l=k+1; l<=N; l++) {
					if (l==N) {
						break;
						return 0;
					}

					else if (d[l]>d[k]) {
						v -= c[k];
						litros[l] = v;
						k = a (litros, l, v, d, c);
						break;
					}
				}
			}

			else {
				romper=true;
				resp = k+1;
				if (resp==r) {
					resp = 0;
				}
				return resp;
				break;
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> Q;
	vector<int> d (N);
	vector<int> c (N);

	cin >> d[0] >> c[0];

    for(int i=1; i<N; i++){
      cin >> d[i] >> c[i];
    }


    for (int j=0; j<Q; j++) {
		int r, v;
		cin >> r >> v;
		vector <int> litros (N, 0);
		litros[r-1]=v;

		romper = false;

		cout << a (litros, r-1, v, d, c) << endl;
	}

	return 0;
}

Compilation message

fountain.cpp: In function 'int a(std::vector<int>&, int, int&, std::vector<int>&, std::vector<int>&)':
fountain.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 328 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 10 ms 332 KB Output is correct
6 Correct 8 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1581 ms 5888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 328 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 10 ms 332 KB Output is correct
6 Correct 8 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
8 Execution timed out 1581 ms 5888 KB Time limit exceeded
9 Halted 0 ms 0 KB -