Submission #994965

#TimeUsernameProblemLanguageResultExecution timeMemory
994965salmonTrains (BOI24_trains)C++14
100 / 100
199 ms249800 KiB
#include <bits/stdc++.h> using namespace std; vector<int> v; map<int,long long int> mep[100100]; vector<int> rebove[100100]; int N; long long int d,x; vector<pair<int,int>> iv; long long int num[100100]; long long int mod = 1'000'000'007; const int B = 300; long long int blom[100100][B + 5]; int main(){ scanf(" %d",&N); for(int i = 0; i < N; i++){ scanf(" %lld",&d); scanf(" %lld",&x); iv.push_back({d,x}); num[i] = 0; if(d <= B) rebove[min((long long int)N,i + d * x)].push_back(i); } num[0]= 1; long long int sum = 0; for(int i = 0; i < N; i++){ num[i] %= mod; for(int j : rebove[i]){ blom[i][iv[j].first] -= num[j]; blom[i][iv[j].first] %= mod; } if(iv[i].first <= B){ blom[i][iv[i].first] += num[i]; blom[i][iv[i].first] %= mod; } else{ int d = iv[i].first; int x = iv[i].second; for(int j = 1; j <= x && i + j * d < N; j++){ num[i + j * d] += num[i]; } } for(int j = 1; j <= B; j++){ num[min(N,i + j)] += blom[i][j]; blom[min(N,i + j)][j] += blom[i][j]; blom[min(N,i + j)][j] %= mod; } sum = (sum + num[i]) % mod; } printf("%lld",(sum + mod) % mod); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf(" %d",&N);
      |  ~~~~~^~~~~~~~~~
Main.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf(" %lld",&d);
      |   ~~~~~^~~~~~~~~~~~
Main.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf(" %lld",&x);
      |   ~~~~~^~~~~~~~~~~~
#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...