# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1117220 |
2024-11-23T02:30:58 Z |
hoangnoobpro |
Deda (COCI17_deda) |
C++17 |
|
591 ms |
5828 KB |
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define nmax 400007
#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 build(ll id,ll l,ll r)
{
if(l==r)
{
st[id]=1e17;
return;
}
ll mid=(l+r)/2;
build(id*2,l,mid);
build(id*2+1,mid+1,r);
st[id]=1e17;
}
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;
build(1,1,n);
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 |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
5 ms |
336 KB |
Output is correct |
4 |
Correct |
591 ms |
5828 KB |
Output is correct |
5 |
Correct |
342 ms |
3400 KB |
Output is correct |
6 |
Correct |
426 ms |
5656 KB |
Output is correct |
7 |
Correct |
448 ms |
5572 KB |
Output is correct |