Submission #1033656

#TimeUsernameProblemLanguageResultExecution timeMemory
1033656vjudge1Trains (BOI24_trains)C++14
21 / 100
69 ms2648 KiB
//#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx,avx2,fma,lzcnt,popcnt") #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #define pf push_front #define ii pair<int,int> #define ill pair<ll,ll> #define el cout<<'\n' #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define int long long const ll mod=1e9+7; const int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; const int nmax=1e5; void add ( int&a , int b ) { if ((a+=b) > mod ) a -= mod ; } void sub ( int&a , int b ) { if ((a-=b) < 0 ) a += mod ; } template<typename T> void chkmin(T& x, T y) {if(x > y) x = y;} template<typename T> void chkmax(T& x, T y) {if(x < y) x = y;} using namespace std; int d[nmax+5]; int x[nmax+5]; int dp[nmax+5]; signed main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n; cin>>n; for(int i=1;i<=n;i++) cin>>d[i]>>x[i]; if(n<=10000) { int ans=0; dp[1]=1; for(int i=1;i<=n;i++) { if(d[i]>=1) for(int j=i+1*d[i];j<=min(n,i+d[i]*x[i]);j+=d[i]) dp[j]=(dp[j]+dp[i])%mod; // cout<<"Wtf"<<i;el; } for(int i=1;i<=n;i++) ans=(ans+dp[i])%mod; cout<<ans;el; } }
#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...