Submission #495470

# Submission time Handle Problem Language Result Execution time Memory
495470 2021-12-18T18:26:15 Z Amer Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
34 / 100
3000 ms 69028 KB
#include <iostream>
#include<map>

using namespace std;

class mem
{
public:
	int maxCombination = 0;
};


const int maxN = 1000005;

int arr[maxN];

map<pair<int, int>, int> memorisation;

int solve(int start, int finish, int mood)
{
	int maxNum = arr[start - 1];

	int memory = memorisation[make_pair(start, finish)];

	if (memory != 0)
	{
		if (memory > mood)
		{
			return false;
		}
		else
		{
			return true;
		}
	}

	for (int i = start; i < finish; i++)
	{
		if (maxNum > arr[i])
		{
			if (arr[i] + maxNum > mood)
			{
				return false;
			}
		}
		else
		{
			maxNum = arr[i];
		}
	}

	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n, m;

    cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	for (int i = 0; i < m; i++)
	{
		int start, finish, mood;

		cin >> start >> finish >> mood;

		cout << solve(start, finish, mood)<<endl;
	}
}

/*
5 2
3 5 1 8 2
1 3 6
2 5 3
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 460 KB Output is correct
12 Correct 6 ms 460 KB Output is correct
13 Correct 5 ms 460 KB Output is correct
14 Correct 9 ms 556 KB Output is correct
15 Correct 11 ms 588 KB Output is correct
16 Correct 16 ms 544 KB Output is correct
17 Correct 14 ms 460 KB Output is correct
18 Correct 15 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2642 ms 69028 KB Output is correct
2 Correct 2725 ms 68820 KB Output is correct
3 Correct 2664 ms 68884 KB Output is correct
4 Correct 2631 ms 68820 KB Output is correct
5 Execution timed out 3099 ms 5960 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 767 ms 7200 KB Output is correct
2 Correct 1987 ms 7052 KB Output is correct
3 Correct 1826 ms 7108 KB Output is correct
4 Correct 1412 ms 7280 KB Output is correct
5 Correct 1221 ms 7364 KB Output is correct
6 Correct 2291 ms 7156 KB Output is correct
7 Correct 2231 ms 7156 KB Output is correct
8 Correct 2487 ms 5300 KB Output is correct
9 Correct 197 ms 3164 KB Output is correct
10 Correct 2950 ms 5412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 460 KB Output is correct
12 Correct 6 ms 460 KB Output is correct
13 Correct 5 ms 460 KB Output is correct
14 Correct 9 ms 556 KB Output is correct
15 Correct 11 ms 588 KB Output is correct
16 Correct 16 ms 544 KB Output is correct
17 Correct 14 ms 460 KB Output is correct
18 Correct 15 ms 560 KB Output is correct
19 Correct 2732 ms 14064 KB Output is correct
20 Correct 2628 ms 14096 KB Output is correct
21 Execution timed out 3049 ms 5704 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 460 KB Output is correct
12 Correct 6 ms 460 KB Output is correct
13 Correct 5 ms 460 KB Output is correct
14 Correct 9 ms 556 KB Output is correct
15 Correct 11 ms 588 KB Output is correct
16 Correct 16 ms 544 KB Output is correct
17 Correct 14 ms 460 KB Output is correct
18 Correct 15 ms 560 KB Output is correct
19 Correct 2642 ms 69028 KB Output is correct
20 Correct 2725 ms 68820 KB Output is correct
21 Correct 2664 ms 68884 KB Output is correct
22 Correct 2631 ms 68820 KB Output is correct
23 Execution timed out 3099 ms 5960 KB Time limit exceeded