답안 #879059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879059 2023-11-26T08:21:47 Z Elvin_Fritl Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
3000 ms 15216 KB
#include <bits/stdc++.h>
using namespace std;
 
#define io                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

 
typedef long long ll;
 
ll bp(ll n,ll m){
    if(m == 0){
        return 1;
    }
    if(m == 1){
        return n;
    }
    if(m%2==0){
        return bp(n*n,m/2);
    }
    return n*bp(n,m-1);
}

 
const int N =  1020, M = 33, inf = 1e9 + 99;
const ll inff = 1e12;

 
 void solve() {
	int n, q;
    cin >> n >> q;
    vector<int> v(n);
    for(int i=0;i<n;i++) {
		cin >> v[i];
	}
	map<pair<int,int>,int> m1 , m2;
    while(q--) {
        int l, r, k;
        cin >> l >> r >> k;
        if(m1[{l,r}] != 0 && (int)m1[{l,r}] <= k) {
			cout << 1 << endl;
			continue;
		}
		if(m2[{l,r}] >= k && m2[{l,r}] > 0) {
			cout << 0 << endl;
			continue;
		}
		
        int mx = v[l - 1], res = 0,ans = 1;
        for(int i=l;i<r;i++) {
            if(mx > v[i]) {
                res = max(res, mx + v[i]);
            }
            mx = max(mx, v[i]);
            if(res > k) {
				ans = 0;
			}
        }
        if(ans == 0) {
			m2[{l,r}] = k;
		}
		else{
			m1[{l,r}] = k;
		}
        
        cout << ans << '\n';
    }
}
 
int main()
{
	io;
	
	int t = 1;
	///  cin >> t;
	while(t--) {
		solve();
	}
    
    return 0;
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 9 ms 860 KB Output is correct
14 Correct 14 ms 1112 KB Output is correct
15 Correct 14 ms 1120 KB Output is correct
16 Correct 16 ms 860 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 14 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3028 ms 15160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3045 ms 15216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 9 ms 860 KB Output is correct
14 Correct 14 ms 1112 KB Output is correct
15 Correct 14 ms 1120 KB Output is correct
16 Correct 16 ms 860 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 14 ms 800 KB Output is correct
19 Execution timed out 3033 ms 10824 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 9 ms 860 KB Output is correct
14 Correct 14 ms 1112 KB Output is correct
15 Correct 14 ms 1120 KB Output is correct
16 Correct 16 ms 860 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 14 ms 800 KB Output is correct
19 Execution timed out 3028 ms 15160 KB Time limit exceeded
20 Halted 0 ms 0 KB -