Submission #1033670

#TimeUsernameProblemLanguageResultExecution timeMemory
1033670vjudge1Trains (BOI24_trains)C++17
21 / 100
2075 ms1372 KiB
#include <stdio.h> const int M = 1e9 + 7; int n, d[100100], x[100100], v[100100]; int main() { scanf("%d", &n); int all1 = 1, res = 0; for (int i = 1; i <= n; ++i) { scanf("%d%d", &d[i], &x[i]); // if (d[i] != 1) all1 = 0; } // if (all1) { // return 0; // } v[1] = 1; for (int i = 1; i <= n; ++i) { if (d[i] && x[i]) { for (int t = 1; t <= x[i]; ++t) { int c = i + t * d[i]; if (c > n) break; v[c] = (v[c] + v[i]) % M; } } } for (int i = 1; i <= n; ++i) res = (res + v[i]) % M; printf("%d", res); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:6:9: warning: unused variable 'all1' [-Wunused-variable]
    6 |     int all1 = 1, res = 0;
      |         ^~~~
Main.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         scanf("%d%d", &d[i], &x[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...