Submission #1051522

#TimeUsernameProblemLanguageResultExecution timeMemory
1051522nisanduuTrains (BOI24_trains)C++14
0 / 100
54 ms3412 KiB
#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)

Main.cpp: In function 'void solve()':
Main.cpp:21:12: warning: unused variable 'am' [-Wunused-variable]
   21 |         ll am = n - ub + 1;
      |            ^~
#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...