제출 #1111491

#제출 시각아이디문제언어결과실행 시간메모리
1111491zhehanTrains (BOI24_trains)C++14
0 / 100
19 ms848 KiB
#include <bits/stdc++.h> using namespace std; int ft[100000+5]; void upd(int p,int v){ while(p<=100000){ ft[p]+=v; p+=p&(-p); } } int qry(int p){ int sum=0; while(p>0){ sum+=ft[p]; p-=p&(-p); } return sum; } int main() { int n,d,x,ways=1; cin>>n; pair<int,int> stops[n+1]; for(int i=0;i<n;++i){ cin>>d>>x; stops[i+1].first=d; stops[i+1].second=x; } upd(1,1); upd(2,-1); for(int i=1;i<=n;++i){ if(qry(i)>0){ int moves=0; if(stops[i].first!=0){ moves=min(stops[i].second,(n-i)/stops[i].first); } ways+=moves; upd(i,1); upd(i+moves*stops[i].first+1,-1); } } cout<<ways<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...