Submission #24984

# Submission time Handle Problem Language Result Execution time Memory
24984 2017-06-19T15:12:35 Z gabrielsimoes Boat (APIO16_boat) C++14
0 / 100
0 ms 17656 KB
#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

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 time Memory Grader output
1 Runtime error 0 ms 17656 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 17656 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 17656 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 17656 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -