Submission #1261903

#TimeUsernameProblemLanguageResultExecution timeMemory
1261903CrabCNHTrains (BOI24_trains)C++20
8 / 100
491 ms1592 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define int long long #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) #define all(v) (v).begin(), (v).end() typedef long long ll; typedef unsigned long long ull; typedef long double ld; using namespace std; template <class T> void minimize (T &t, T f) {if (t > f) t = f;} template <class T> void maximize (T &t, T f) {if (t < f) t = f;} const int maxN = 2e5 + 5; const int inf = 1e18 + 7; const int mod = 1e9 + 7; // khong tu code thi khong kha len duoc dau // biet sol roi thi tu lam not di int d[maxN], x[maxN]; int dp[maxN]; void solve () { int n; cin >> n; for (int i = 1; i <= n; i ++) { cin >> d[i] >> x[i]; } dp[1] = 1; for (int i = 1; i <= n; i ++) { if (d[i] == 0) { continue; } for (int t = 1; t <= x[i]; t ++) { if (i + t * d[i] > n) { break; } (dp[i + t * d[i]] += dp[i]) %= mod; } } int res = 0; for (int i = 1; i <= n; i ++) { (res += dp[i]) % mod; } cout << res; return; } signed main () { cin.tie (nullptr) -> sync_with_stdio (false); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int t = 1; //cin >> t; while (t --) { solve (); } return 0; } // thfv

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:61:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:62:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...