답안 #894842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894842 2023-12-29T05:46:20 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
1503 ms 19736 KB
// Problem: C - Hedgehog Daniyar and Algorithms
// Contest: Virtual Judge - Yosik IOI contest #1
// URL: https://vjudge.net/contest/601761#problem/C
// Memory Limit: 256 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(v) (v).begin(),(v).end()
#define rall(v) ((v).rbegin()), ((v).rend())
#define out(v)  for(auto& i : v) cout << i << ' ';
#define F first
#define S second
#define int long long

const ll N = 1e6 + 400;
const ll MOD = 1e9 + 7;
const string alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int a[N] , b[N] , pref[N];

void solve (){
	int n , m;
	cin >> n >> m;
	int ok = 1;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
	}
	for(int i = 1; i <= n; i ++){
		pref[i] = pref[i - 1];
		if (a[i] < a[i - 1]){
			pref[i] = i;
		}
	}
	if (n <= 5000 && m <= 5000){
		for(int x = 1; x <= m; x ++){
			int l ,r , k;
			cin >> l >> r >> k;
			for(int i = l ; i <= r; i ++){
				b[i] = a[i];
			}
			int mx = b[l] , ok = 1;
			for(int i = l + 1; i <= r; i ++){
				if (b[i] < mx && mx + b[i] > k){
					ok = 0;
					break;
				}
				mx = max(b[i] , mx);
			}
			cout << ok << endl;
		}
	}
	else {
		for(int x = 1; x <= m; x++){
			int l , r , k;
			cin >> k >> r >> k;
			cout << (pref[r] <= l) << endl;
		}
	}
}

signed main(){
	// freopen("ones.in" , "r" , stdin) ;
	// freopen("ones.out" , "w" , stdout) ;
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	// int cs = 1;
	// cin >>T;
	while (T --){
		// cout <<"Case " << cs ++<< ":" << endl;
		solve ();
		// cout <<endl;
	}
}

Compilation message

sortbooks.cpp: In function 'void solve()':
sortbooks.cpp:31:6: warning: unused variable 'ok' [-Wunused-variable]
   31 |  int ok = 1;
      |      ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4692 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4692 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 5 ms 4444 KB Output is correct
12 Correct 5 ms 4608 KB Output is correct
13 Correct 6 ms 4700 KB Output is correct
14 Correct 10 ms 4700 KB Output is correct
15 Correct 9 ms 4700 KB Output is correct
16 Correct 21 ms 4700 KB Output is correct
17 Correct 19 ms 4696 KB Output is correct
18 Correct 18 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1503 ms 19736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4692 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 5 ms 4444 KB Output is correct
12 Correct 5 ms 4608 KB Output is correct
13 Correct 6 ms 4700 KB Output is correct
14 Correct 10 ms 4700 KB Output is correct
15 Correct 9 ms 4700 KB Output is correct
16 Correct 21 ms 4700 KB Output is correct
17 Correct 19 ms 4696 KB Output is correct
18 Correct 18 ms 4444 KB Output is correct
19 Incorrect 303 ms 13648 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4692 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 5 ms 4444 KB Output is correct
12 Correct 5 ms 4608 KB Output is correct
13 Correct 6 ms 4700 KB Output is correct
14 Correct 10 ms 4700 KB Output is correct
15 Correct 9 ms 4700 KB Output is correct
16 Correct 21 ms 4700 KB Output is correct
17 Correct 19 ms 4696 KB Output is correct
18 Correct 18 ms 4444 KB Output is correct
19 Incorrect 1503 ms 19736 KB Output isn't correct
20 Halted 0 ms 0 KB -