Submission #994709

#TimeUsernameProblemLanguageResultExecution timeMemory
994709salmonTrains (BOI24_trains)C++14
0 / 100
46 ms28848 KiB
#include <bits/stdc++.h> using namespace std; vector<int> v; set<int> sat[100100]; int N; int d,x; vector<pair<int,int>> iv; long long int num[100100]; long long int mod = 1'000'000'007; vector<vector<int>> w; map<int,int> mep; int main(){ scanf(" %d",&N); for(int i = 0; i < N; i++){ scanf(" %d",&d); scanf(" %d",&x); v.push_back(d); iv.push_back({d,x}); num[i] = 0; } for(int i = 0; i < N; i++){ if(iv[i].first != 0){ d = iv[i].first; x = iv[i].second; for(int j = 1; j <= x && j * d + i < N; j++){ sat[j * d + i].insert(d); if(iv[j * d + i].first == d){ x = max(x,j + iv[j * d + i].second); iv[j * d + i] = {0,0}; } } } } num[0] = 1; long long int sum = 1; for(int i = 1; i < N; i++){ for(int j : sat[i]){ num[i] += num[i - j]; } num[i] %= mod; sum = (sum + num[i]) % mod; } printf("%lld",sum); }

Compilation message (stderr)

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