답안 #480033

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480033 2021-10-14T12:28:15 Z levsog2004 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
3000 ms 81860 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef  long long ll;
#define all(x) x.begin(),x.end()
#define al(a,n)  (a,a+n)
#define se second
#define fr first
#define m_p make_pair
const ll N = 2000004;
const ll mod = 1000 * 1000 * 1000 + 7;
const ll inf = 1000000000;
ll n, m, k, z, t, ans, x,y, pat,a[N];
int main()
{

	cin >> n >> m;
	k = m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	map <ll, ll> mp;
	int j = 0;
	for (int i = 0; i < n; ++i)
	{
		j = max(j, i);
		while (j < n - 1 && a[j] <= a[j + 1])
			++j;
		mp[i] = j;
	}
	while (m--)
	{
		cin >> x >> y >> z;
		x--;
		y--;
		if (n*k > 5000 * 5000)
		{
			if (mp[x] < y)
				cout << 0 << endl;
			else
				cout << 1 << endl;
		}
		else
		{
			vector<ll> v;
			for (int i = x; i <= y; ++i)
			{
				v.push_back(a[x]);
			}
			sort(all(v));
			ll p = 0;
			for (int i = v.size() - 1; i >= 0; ++i)
			{
				if (v[i] != a[i])
				{
					p = v[i];
					break;
				}
			}
			if (v[0] + p > z)
				cout << 0 << endl;
			else
				cout << 1 << endl;
		}
	}
		return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3071 ms 81860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 351 ms 9504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -