# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051522 | nisanduu | Trains (BOI24_trains) | C++14 | 54 ms | 3412 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
void solve(){
ll n;
cin>>n;
vector<ll> d(1e5 + 10),x(1e5 + 10);
vector<ll> dp(1e5 + 10,-1);
for(ll i=1;i<=n;i++){
ll a,b;
cin>>a>>b;
d[i]=a;
x[i]=b;
}
ll ans = 0;
vector<ll> pref(n+10,0);
for(ll i=n;i>=1;i--){
ll ub = min(n,i+x[i]);
ll am = n - ub + 1;
pref[i] = pref[i+1] - pref[ub+1] + 1;
}
for(ll i=1;i<=n;i++){
cout<<pref[i]<<endl;
ans += (pref[i] - 1);
}
ans++;
cout<<ans<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |