# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1117219 |
2024-11-23T02:30:01 Z |
hoangnoobpro |
Deda (COCI17_deda) |
C++17 |
|
526 ms |
9260 KB |
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define nmax 200007
#define fi first
#define se second
#define ll long long
ll t=1,n,m=0,i=0,j=0,d=0,x=0,k=0,y=0,z,a[nmax],st[nmax*4],l,r,mid,kq;
char ch;
void update(ll id,ll l,ll r,ll vt,ll gt)
{
if(r<vt||l>vt)return;
if(l==r)
{
st[id]=gt;
return;
}
ll mid=(l+r)/2;
update(id*2,l,mid,vt,gt);
update(id*2+1,mid+1,r,vt,gt);
st[id]=min(st[id*2],st[id*2+1]);
}
void get(ll id,ll l,ll r,ll u,ll v)
{
if(r<u||l>v)return;
if(u<=l&&r<=v)
{
d=min(d,st[id]);
return;
}
ll mid=(l+r)/2;
get(id*2,l,mid,u,v);
get(id*2+1,mid+1,r,u,v);
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>t;
for(i=1;i<nmax-2;++i)st[i]=1e17;
while(t--)
{
cin>>ch>>x>>y;
if(ch=='M')
{
update(1,1,n,y,x);
continue;
}
l=y;
r=n;
kq=-1;
while(l<=r)
{
mid=(l+r)/2;
d=1e17;
get(1,1,n,y,mid);
if(d<=x)
{
kq=mid;
r=mid-1;
}
else l=mid+1;
}
cout<<kq<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
5 ms |
2640 KB |
Output is correct |
4 |
Incorrect |
526 ms |
9260 KB |
Output isn't correct |
5 |
Incorrect |
323 ms |
6748 KB |
Output isn't correct |
6 |
Incorrect |
376 ms |
8776 KB |
Output isn't correct |
7 |
Incorrect |
400 ms |
9032 KB |
Output isn't correct |