답안 #837038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837038 2023-08-24T20:07:58 Z MODDI Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
3000 ms 37088 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vi arr;
int main(){
	cin>>n>>m;
	for(int i = 0; i < n; i++){
		int a;
		cin>>a;
		arr.pb(a);
	}
	while(m--){
		int l, r, k;
		cin>>l>>r>>k;
		l--; r--;
		bool can = true;
		set<int> store;
		set<int> s;
		for(int i = l; i <= r; i++)	s.insert(arr[i]);
		
		vi arrr;
		for(auto t : s)	arrr.pb(t);
		
		int id = arrr.size()-1;
		for(int i = r; i >= l; i--){
			while(id>=0 && store.find(arrr[id]) != store.end()){
				store.erase(arrr[id]);id--;
			}
//			cout<<i<<endl;
//			for(auto t : store)
//				cout<<t<<" ";
//			cout<<endl;
			if(store.size() == 0)	store.insert(arr[i]);
			else{
				if(arr[i] + *store.rbegin() > k){
					can = false;
					break;
				}
				else	store.insert(arr[i]);
			}
		}
		cout<<can<<endl;
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 9 ms 340 KB Output is correct
7 Correct 9 ms 340 KB Output is correct
8 Correct 19 ms 340 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Incorrect 3 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 9 ms 340 KB Output is correct
7 Correct 9 ms 340 KB Output is correct
8 Correct 19 ms 340 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Incorrect 3 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3018 ms 37088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3008 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 9 ms 340 KB Output is correct
7 Correct 9 ms 340 KB Output is correct
8 Correct 19 ms 340 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Incorrect 3 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 9 ms 340 KB Output is correct
7 Correct 9 ms 340 KB Output is correct
8 Correct 19 ms 340 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Incorrect 3 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -