Submission #760789

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7607892023-06-18 12:57:12bachhoangxuanFountain (eJOI20_fountain)C++17
100 / 100
301 ms10264 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 100005
const int inf=1e18;
const int bl=320;
int n,q,a[maxn],x[maxn],nxt[maxn],sum[maxn],sxt[maxn];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
for(int i=1;i<=n;i++)cin >> a[i] >> x[i];
a[n+1]=x[n+1]=inf;
vector<int> Max;Max.push_back(n+1);
for(int i=n;i>=1;i--){
while(a[i]>=a[Max.back()]) Max.pop_back();
nxt[i]=Max.back();Max.push_back(i);
}
for(int i=1;i<=n;i++){
int u=i;
for(int j=0;j<bl;j++){
sum[i]+=x[u];
if(u==n+1) break;
else u=nxt[u];
}
sxt[i]=u;
}
for(int i=1;i<=q;i++){
int r,v;cin >> r >> v;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...