Submission #889768

# Submission time Handle Problem Language Result Execution time Memory
889768 2023-12-20T07:02:06 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 30272 KB
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define sz size()
#define vi vector<int>
#define bk back()
#define fr front()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define itn int
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=2e5+5,mod=1e9+7;
/*
20.12.23
WEDNESDAY
*/
void at(bool ok){
	if(ok) cout<<"YES\n";
	else cout<<"NO\n";
}
pii c[maxn];
vi b;
map<int,int> d;
int n,q,a[maxn];
void solve(){
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>a[i];d[a[i]]=i;
	}
	while(q--){
		int l,r,k,sum=0;
		cin>>l>>r>>k;
		b.clear();
		for(int i=l;i<=r;++i) b.pb(a[i]),c[i]={a[i],i};
		sort(c+1+l,c+r+1);
		for(auto it:b) sum+=abs(c[it].s-d[it]);
		if(sum<=k) cout<<"1\n";
		else cout<<"0\n";
	}
}
signed main(){
	//freopen("A.in","r",stdin),freopen("A.out","w",stdout);
	ios_base::sync_with_stdio(0);cin.tie(0);
	int T=1;
//	cin>>T;
	for(int i=1;i<=T;i++){
//		cout<<"Case #"<<i<<": ";
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 94 ms 30272 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 5868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -