# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994737 | 2024-06-08T04:44:41 Z | salmon | Trains (BOI24_trains) | C++14 | 50 ms | 38860 KB |
#include <bits/stdc++.h> using namespace std; vector<int> v; map<int,long long int> mep[100100]; vector<int> rebove[100100]; int N; int d,x; vector<pair<int,int>> iv; long long int num[100100]; long long int mod = 1'000'000'007; int main(){ scanf(" %d",&N); for(int i = 0; i < N; i++){ scanf(" %d",&d); scanf(" %d",&x); iv.push_back({d,x}); num[i] = 0; rebove[(long long int)min((long long int)N,i + (long long int)d * x)].push_back(i); } /*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 = 0; for(int i = 0; i < N; i++){ for(pair<int,long long int> j : mep[i]){ num[i] += j.second; } num[i] %= mod; mep[i + iv[i].first][iv[i].first] += num[i]; for(int j : rebove[i]){ mep[i][iv[j].first] -= num[j]; mep[i][iv[j].first] %= mod; } for(pair<int,long long int> j : mep[i]){ if(j.second == 0) continue; mep[min(N,i + j.first)][j.first] += j.second; } sum = (sum + num[i]) % mod; //printf("%lld\n",num[i]); } printf("%lld",(sum + mod) % mod); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8028 KB | Output is correct |
2 | Correct | 2 ms | 7860 KB | Output is correct |
3 | Correct | 2 ms | 8028 KB | Output is correct |
4 | Correct | 2 ms | 8028 KB | Output is correct |
5 | Correct | 2 ms | 8024 KB | Output is correct |
6 | Correct | 2 ms | 8028 KB | Output is correct |
7 | Correct | 2 ms | 8028 KB | Output is correct |
8 | Runtime error | 11 ms | 16032 KB | Execution killed with signal 11 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8028 KB | Output is correct |
2 | Correct | 2 ms | 7860 KB | Output is correct |
3 | Correct | 2 ms | 8028 KB | Output is correct |
4 | Correct | 2 ms | 8028 KB | Output is correct |
5 | Correct | 2 ms | 8024 KB | Output is correct |
6 | Correct | 2 ms | 8028 KB | Output is correct |
7 | Correct | 2 ms | 8028 KB | Output is correct |
8 | Runtime error | 11 ms | 16032 KB | Execution killed with signal 11 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 8280 KB | Output is correct |
2 | Correct | 3 ms | 8540 KB | Output is correct |
3 | Correct | 3 ms | 8340 KB | Output is correct |
4 | Correct | 6 ms | 8796 KB | Output is correct |
5 | Correct | 21 ms | 15236 KB | Output is correct |
6 | Correct | 21 ms | 15560 KB | Output is correct |
7 | Correct | 22 ms | 15816 KB | Output is correct |
8 | Correct | 2 ms | 8028 KB | Output is correct |
9 | Correct | 1 ms | 8028 KB | Output is correct |
10 | Correct | 2 ms | 8028 KB | Output is correct |
11 | Correct | 4 ms | 8876 KB | Output is correct |
12 | Correct | 22 ms | 15820 KB | Output is correct |
13 | Correct | 2 ms | 8028 KB | Output is correct |
14 | Correct | 5 ms | 8760 KB | Output is correct |
15 | Correct | 43 ms | 15560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 38860 KB | Output is correct |
2 | Correct | 46 ms | 33748 KB | Output is correct |
3 | Correct | 35 ms | 21960 KB | Output is correct |
4 | Correct | 40 ms | 31324 KB | Output is correct |
5 | Runtime error | 7 ms | 15964 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8028 KB | Output is correct |
2 | Correct | 2 ms | 7860 KB | Output is correct |
3 | Correct | 2 ms | 8028 KB | Output is correct |
4 | Correct | 2 ms | 8028 KB | Output is correct |
5 | Correct | 2 ms | 8024 KB | Output is correct |
6 | Correct | 2 ms | 8028 KB | Output is correct |
7 | Correct | 2 ms | 8028 KB | Output is correct |
8 | Runtime error | 11 ms | 16032 KB | Execution killed with signal 11 |
9 | Halted | 0 ms | 0 KB | - |