# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
339081 | Khizri | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 3073 ms | 33388 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
//------------------------------------------------------------------------------
//******************************************************************************
#define IOS ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0)
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define ll long long
#define MOD 1e9+7
#define endl '\n'
const int mxn=1e6+5;
//******************************************************************************
//------------------------------------------------------------------------------
ll t=1,n,m,arr[mxn],l,r,k;
vector<ll>vt[1010];
bool binary_search(ll ind,ll a,ll b){
ll l=0,r=vt[ind].size()-1;
while(l<=r){
ll m=(l+r)/2;
if(vt[ind][m]>b){
r=m-1;
}
else if(vt[ind][m]<a){
l=m+1;
}
else{
//cout<<m<<endl;
return true;
}
}
return false;
}
bool funk(){
multiset<ll>st;
for(int i=l;i<=r;i++){
st.insert(arr[i]);
}
for(int i=l;i<=r;i++){
st.erase(st.find(arr[i]));
multiset<ll>::iterator it=st.lower_bound(arr[i]);
if(it!=st.begin()){
it--;
if((*it)+arr[i]>k){
return false;
}
}
}
return true;
}
bool f(){
for(ll i=l;i<r;i++){
for(int j=arr[i]-1;j>max(-1ll,k-arr[i]);j--){
if(binary_search(j,i+1,r)){
return false;
}
}
}
return true;
}
void solve(){
bool x=true;
scanf("%lld %lld",&n,&m);
for(int i=1;i<=n;i++){
scanf("%lld",&arr[i]);
if(arr[i]>1000) x=false;
if(x) vt[arr[i]].pb(i);
}
while(m--){
scanf("%lld %lld %lld",&l,&r,&k);
int q;
if(x){
q=f();
}
else{
q=funk();
}
printf("%d\n",q);
}
}
int main(){
//IOS;
//cin>>t;
while(t--){
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |