Submission #24984

#TimeUsernameProblemLanguageResultExecution timeMemory
24984gabrielsimoesBoat (APIO16_boat)C++14
0 / 100
0 ms17656 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD = 1000000007;
const int MAXN = 500;
const int MAX = 1e6+10;

int n;
ll a[MAXN], b[MAXN];
ll dp[MAX], sum[MAX];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lld %lld", &a[i], &b[i]),
								assert(a[i] < MAX && b[i] < MAX);
	
	for (int i = 0; i < MAX; i++) sum[i] = 1;
	for (int i = 0; i < n; i++) {
		for (int k = b[i]; k >= a[i]; k--)
			dp[k] = (dp[k] + sum[k-1]) % MOD;
		for (int i = 1; i < MAX; i++)
			sum[i] = (sum[i-1] + dp[i]) % MOD;
	}

	printf("%lld\n", sum[MAX-1] - 1);
}

Compilation message (stderr)

boat.cpp: In function 'int main()':
boat.cpp:15:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
boat.cpp:17:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         assert(a[i] < MAX && b[i] < MAX);
                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...