제출 #912507

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
9125072024-01-19 14:46:56androFountain (eJOI20_fountain)C++14
100 / 100
921 ms25936 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+50;
int n;
int q;
int koliko[N];
int staje[N];
int up[N][21];
int suf[N];
stack<int>s;
int P[N];
int kti(int n,int k){
for(int i=0;i<=20;i++){
if(k&(1ll<<i))n=up[n][i];
}
return n;
}
signed main(){
cin>>n>>q;
for(int i=1;i<=n;i++)cin>>koliko[i]>>staje[i];
for(int i=0;i<=n;i++)P[i]=0;
for(int i=n;i>=1;i--){
while(s.size()&&koliko[s.top()]<=koliko[i])s.pop();
if(s.size())P[i]=s.top();
s.push(i);
}
for(int i=0;i<=n;i++)suf[i]=0;
for(int i=1;i<=n;i++)if(!P[i])suf[i]=staje[i];
for(int i=n;i>=1;i--){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...