답안 #433852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433852 2021-06-20T11:28:27 Z JeanBombeur Boat (APIO16_boat) C++17
31 / 100
1454 ms 524292 KB
#include <iostream>
#include <cstdio>
#include <vector>
#define int long long
using namespace std;

//  <|°_°|>

const int MOD = (1000 * 1000 * 1000 + 7);
const int MAX_GROUPES = (501);

vector <int> DP[MAX_GROUPES];

pair <int, int> Bornes[MAX_GROUPES];

int nbGroupes;

void Read() {
	scanf("%lld", &nbGroupes);
	nbGroupes ++;
	for (int i = 1; i < nbGroupes; i ++)
	{
		scanf("%lld %lld", &Bornes[i].first, &Bornes[i].second);
		for (int j = Bornes[i].first; j <= Bornes[i].second; j ++)
		{
			DP[i].push_back(0);
		}
	}
	DP[0].push_back(1);
	return;
}

void Solve() {
	int sum = -1;
	for (int i = 0; i < nbGroupes; i ++)
	{
		int sz = DP[i].size();
		for (int k = 0; k < sz; k ++)
		{
			DP[i][k] %= MOD;
			sum += DP[i][k];
			if (k < sz - 1)
				DP[i][k + 1] += DP[i][k];
			for (int j = i + 1; j < nbGroupes; j ++)
			{
				if (Bornes[j].second > Bornes[i].first + k)
				{
					DP[j][max(0LL, Bornes[i].first + k + 1 - Bornes[j].first)] += DP[i][k];
				}
			}
		}
	}
	printf("%lld\n", sum % MOD);
	return;
}

signed main() {
	Read();
	Solve();
	return 0;
}

Compilation message

boat.cpp: In function 'void Read()':
boat.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%lld", &nbGroupes);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~
boat.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%lld %lld", &Bornes[i].first, &Bornes[i].second);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 960 ms 8844 KB Output is correct
22 Correct 967 ms 8780 KB Output is correct
23 Correct 875 ms 8416 KB Output is correct
24 Correct 1036 ms 9012 KB Output is correct
25 Correct 1122 ms 9100 KB Output is correct
26 Correct 1454 ms 8328 KB Output is correct
27 Correct 1396 ms 8316 KB Output is correct
28 Correct 1438 ms 8316 KB Output is correct
29 Correct 1448 ms 8320 KB Output is correct
30 Correct 866 ms 9932 KB Output is correct
31 Correct 898 ms 9916 KB Output is correct
32 Correct 867 ms 10024 KB Output is correct
33 Correct 902 ms 9616 KB Output is correct
34 Correct 892 ms 9800 KB Output is correct
35 Correct 704 ms 9336 KB Output is correct
36 Correct 683 ms 9732 KB Output is correct
37 Correct 681 ms 9748 KB Output is correct
38 Correct 710 ms 9608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 546 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 960 ms 8844 KB Output is correct
22 Correct 967 ms 8780 KB Output is correct
23 Correct 875 ms 8416 KB Output is correct
24 Correct 1036 ms 9012 KB Output is correct
25 Correct 1122 ms 9100 KB Output is correct
26 Correct 1454 ms 8328 KB Output is correct
27 Correct 1396 ms 8316 KB Output is correct
28 Correct 1438 ms 8316 KB Output is correct
29 Correct 1448 ms 8320 KB Output is correct
30 Correct 866 ms 9932 KB Output is correct
31 Correct 898 ms 9916 KB Output is correct
32 Correct 867 ms 10024 KB Output is correct
33 Correct 902 ms 9616 KB Output is correct
34 Correct 892 ms 9800 KB Output is correct
35 Correct 704 ms 9336 KB Output is correct
36 Correct 683 ms 9732 KB Output is correct
37 Correct 681 ms 9748 KB Output is correct
38 Correct 710 ms 9608 KB Output is correct
39 Runtime error 546 ms 524292 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -