Submission #1049354

#TimeUsernameProblemLanguageResultExecution timeMemory
1049354YassirSalamaTrains (BOI24_trains)C++17
0 / 100
28 ms4320 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #ifdef IOI template<typename T> void dbg(const T&t){ cout<<t<<endl; } template<typename T,typename... Args> void dbg(const T& t,const Args&... args){ cout<<t<<" , "; dbg(args...); } #define dbg(...) cout<<"("<<#__VA_ARGS__<<"): ";dbg(__VA_ARGS__); #else #define dbg(...) 1337; #endif #define F first #define S second const int maxn=1e5+100; const int mod=1e9+7; signed main(){ int n; cin>>n; int dp[n+1]; memset(dp,0,sizeof(dp)); dp[1]=1; set<pair<int,int>> s; int cnt=0; bool ok=false; for(int i=1;i<=n;i++){ while((*s.begin()).F==i){ cnt-=(*s.begin()).S; s.erase(s.begin()); } int d,x; cin>>d>>x; if(d!=1) ok=true; dp[i]+=cnt; dp[i]%=mod; cnt+=dp[i]; cnt%=mod; s.insert({i+x+1,dp[i]}); } int ans=0; for(int i=1;i<=n;i++){ ans+=dp[i]; ans%=mod; } printf("%lld\n",ans); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:31:10: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   31 |     bool ok=false;
      |          ^~
#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...