답안 #30795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30795 2017-07-26T14:12:17 Z cdemirer Boat (APIO16_boat) C++14
9 / 100
2000 ms 9840 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define MOD ((ll)1e9+7)
#define safeadd(x, y) ( ( ((ll)x % MOD) + ((ll)y % MOD) ) % MOD )

int N;
map<int, ll> dp[500];
int A[500], B[500];

ll func(int x, int s) {
	//cerr << "called: " << x << " " << s << endl;
	if (dp[x][s] != 0) return dp[x][s];
	ll sum = 0;
	if (x < N-1) sum = safeadd(sum, func(x+1, s));
	else sum = safeadd(sum, 1);
	for (int i = max(s+1, A[x]); i <= B[x]; i++) {
		if (x < N-1) sum = safeadd(sum, func(x+1, i));
		else sum = safeadd(sum, 1);
	}
	dp[x][s] = sum;
	//cerr << "returned: " << sum << endl;
	return dp[x][s];
}

int main(int argc, char **argv) {

	//freopen("input", "r", stdin);
	//freopen("output", "w", stdout);

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &(A[i]), &(B[i]));
	}
	printf("%lld\n", safeadd(func(0, 0), -1));
	

	return 0;
}

Compilation message

boat.cpp: In function 'int main(int, char**)':
boat.cpp:39:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
boat.cpp:41:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &(A[i]), &(B[i]));
                                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 9840 KB Output is correct
2 Correct 79 ms 9840 KB Output is correct
3 Correct 89 ms 9840 KB Output is correct
4 Correct 89 ms 9840 KB Output is correct
5 Correct 79 ms 9840 KB Output is correct
6 Correct 93 ms 9840 KB Output is correct
7 Correct 83 ms 9840 KB Output is correct
8 Correct 79 ms 9840 KB Output is correct
9 Correct 89 ms 9840 KB Output is correct
10 Correct 73 ms 9840 KB Output is correct
11 Correct 89 ms 9840 KB Output is correct
12 Correct 86 ms 9840 KB Output is correct
13 Correct 63 ms 9840 KB Output is correct
14 Correct 89 ms 9840 KB Output is correct
15 Correct 86 ms 9840 KB Output is correct
16 Correct 13 ms 4296 KB Output is correct
17 Correct 13 ms 4428 KB Output is correct
18 Correct 16 ms 4428 KB Output is correct
19 Correct 16 ms 4428 KB Output is correct
20 Correct 13 ms 4296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 9840 KB Output is correct
2 Correct 79 ms 9840 KB Output is correct
3 Correct 89 ms 9840 KB Output is correct
4 Correct 89 ms 9840 KB Output is correct
5 Correct 79 ms 9840 KB Output is correct
6 Correct 93 ms 9840 KB Output is correct
7 Correct 83 ms 9840 KB Output is correct
8 Correct 79 ms 9840 KB Output is correct
9 Correct 89 ms 9840 KB Output is correct
10 Correct 73 ms 9840 KB Output is correct
11 Correct 89 ms 9840 KB Output is correct
12 Correct 86 ms 9840 KB Output is correct
13 Correct 63 ms 9840 KB Output is correct
14 Correct 89 ms 9840 KB Output is correct
15 Correct 86 ms 9840 KB Output is correct
16 Correct 13 ms 4296 KB Output is correct
17 Correct 13 ms 4428 KB Output is correct
18 Correct 16 ms 4428 KB Output is correct
19 Correct 16 ms 4428 KB Output is correct
20 Correct 13 ms 4296 KB Output is correct
21 Execution timed out 2000 ms 4164 KB Execution timed out
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2000 ms 2052 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 9840 KB Output is correct
2 Correct 79 ms 9840 KB Output is correct
3 Correct 89 ms 9840 KB Output is correct
4 Correct 89 ms 9840 KB Output is correct
5 Correct 79 ms 9840 KB Output is correct
6 Correct 93 ms 9840 KB Output is correct
7 Correct 83 ms 9840 KB Output is correct
8 Correct 79 ms 9840 KB Output is correct
9 Correct 89 ms 9840 KB Output is correct
10 Correct 73 ms 9840 KB Output is correct
11 Correct 89 ms 9840 KB Output is correct
12 Correct 86 ms 9840 KB Output is correct
13 Correct 63 ms 9840 KB Output is correct
14 Correct 89 ms 9840 KB Output is correct
15 Correct 86 ms 9840 KB Output is correct
16 Correct 13 ms 4296 KB Output is correct
17 Correct 13 ms 4428 KB Output is correct
18 Correct 16 ms 4428 KB Output is correct
19 Correct 16 ms 4428 KB Output is correct
20 Correct 13 ms 4296 KB Output is correct
21 Execution timed out 2000 ms 4164 KB Execution timed out
22 Halted 0 ms 0 KB -