답안 #497570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497570 2021-12-23T09:54:58 Z Nuraly_Serikbay Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
30 / 100
3000 ms 26052 KB
/*	Speech to the young  */

#include <bits/stdc++.h>
 
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;

 
using namespace std;

#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse,-fgcse-lm")
#pragma GCC optimize("-ftree-pre,-ftree-vrp")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")

  
typedef long long ull;
typedef unsigned long long ll;
typedef string S;
typedef double D;
  
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const int INF = 2e9 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const D eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
  
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}

void pre (ll a) {
    cout << fixed << setprecision(a);
    return;
} 

ll n, q, a[N], pref[N];
ll b[N], mn = INF;

void Solutions () {
	cin >> n >> q;
	for (int i = 1; i <= n; ++ i) {
		cin >> a[i];
		mn = min (mn, a[i]);
	}
	for (int i = 1; i < n; ++ i) {
		if (a[i] > a[i + 1]) b[i] = 1;
		pref[i] = pref[i - 1] + b[i];
	}
	pref[n] = pref[n - 1];
	while (q --) {
		ll l, r, k, mx = 0;
		cin >> l >> r >> k;
		if (mn > k) {
			if (pref[r - 1] - pref[l - 1] == 0) cout << 1 << '\n';
			else cout << 0 << '\n';
			continue;
		}
		for (int i = l; i < r; ++ i) {
			for (int j = i + 1; j <= r; ++ j) {
				if (a[j] >= a[i]) break;
				mx = max (mx, a[i] + a[j]);
			}
		}
		if (mx > k) cout << 0 << '\n';
		else cout << 1 << '\n';
		
	}
	return;
}

int main(){
	Zymraq();
	Solutions ();
	exit (0);
}

Compilation message

sortbooks.cpp: In function 'void Solutions()':
sortbooks.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   63 |  for (int i = 1; i <= n; ++ i) {
      |                  ~~^~~~
sortbooks.cpp:67:20: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   67 |  for (int i = 1; i < n; ++ i) {
      |                  ~~^~~
sortbooks.cpp:80:21: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   80 |   for (int i = l; i < r; ++ i) {
      |                   ~~^~~
sortbooks.cpp:81:26: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   81 |    for (int j = i + 1; j <= r; ++ j) {
      |                        ~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 2 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 17 ms 404 KB Output is correct
12 Correct 56 ms 472 KB Output is correct
13 Correct 65 ms 484 KB Output is correct
14 Correct 107 ms 452 KB Output is correct
15 Correct 126 ms 576 KB Output is correct
16 Correct 94 ms 464 KB Output is correct
17 Correct 17 ms 452 KB Output is correct
18 Correct 28 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 497 ms 26052 KB Output is correct
2 Correct 499 ms 25748 KB Output is correct
3 Correct 499 ms 25764 KB Output is correct
4 Correct 500 ms 25896 KB Output is correct
5 Correct 453 ms 17888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3058 ms 2684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 2 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 17 ms 404 KB Output is correct
12 Correct 56 ms 472 KB Output is correct
13 Correct 65 ms 484 KB Output is correct
14 Correct 107 ms 452 KB Output is correct
15 Correct 126 ms 576 KB Output is correct
16 Correct 94 ms 464 KB Output is correct
17 Correct 17 ms 452 KB Output is correct
18 Correct 28 ms 460 KB Output is correct
19 Execution timed out 3006 ms 5060 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 2 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 17 ms 404 KB Output is correct
12 Correct 56 ms 472 KB Output is correct
13 Correct 65 ms 484 KB Output is correct
14 Correct 107 ms 452 KB Output is correct
15 Correct 126 ms 576 KB Output is correct
16 Correct 94 ms 464 KB Output is correct
17 Correct 17 ms 452 KB Output is correct
18 Correct 28 ms 460 KB Output is correct
19 Correct 497 ms 26052 KB Output is correct
20 Correct 499 ms 25748 KB Output is correct
21 Correct 499 ms 25764 KB Output is correct
22 Correct 500 ms 25896 KB Output is correct
23 Correct 453 ms 17888 KB Output is correct
24 Execution timed out 3058 ms 2684 KB Time limit exceeded
25 Halted 0 ms 0 KB -