Submission #38740

#TimeUsernameProblemLanguageResultExecution timeMemory
38740bakuritsBoat (APIO16_boat)C++14
0 / 100
0 ms2408 KiB
#include <iostream> #include <stdio.h> const int N = 510; const int BIG_N = 1e5; const int rem = 1e9 + 7; using namespace std; int n; int A[N], B[N]; int dp[BIG_N]; void print() { for (int i = 1; i < BIG_N; i++) { printf("%d ", dp[i]); } puts(""); } int main() { scanf ("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &A[i], &B[i]); } dp[0] = 1; for (int i = 1; i <= n; i++) { int sum = 0; for (int j = 0; j < A[i]; j++) { sum = (sum + dp[j]) % rem; } for (int j = A[i]; j <= B[i]; j++) { int sm = dp[j]; dp[j] = (dp[j] + sum) % rem; sum = (sum + sm) % rem; } // print(); } int ans = 0; for (int i = 1; i < BIG_N; i++) { ans = (ans + dp[i]) % rem; } printf("%d", ans); }

Compilation message (stderr)

boat.cpp: In function 'int main()':
boat.cpp:23:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d", &n);
                     ^
boat.cpp:25:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &A[i], &B[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...