답안 #105724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105724 2019-04-14T06:08:23 Z Pro_ktmr Boat (APIO16_boat) C++14
9 / 100
942 ms 525312 KB
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define MOD 1000000007

int N;
int a[500],b[500];
vector<int> zaatu;

int dp[500][1002] = {};
int solve(int now, int bef){
	if(now == N) return 1;
	if(dp[now][bef] != 0) return dp[now][bef];
	LL ans = solve(now+1,bef);
	for(int i=max(zaatu[bef]+1,a[now]); i<b[now]; i++){
		ans += solve(now+1, lower_bound(zaatu.begin(), zaatu.end(), i)-zaatu.begin());
		ans %= MOD;
	}
	return dp[now][bef] = ans % MOD;
}

int main(){
	
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d%d", a+i, b+i);
		b[i]++;
		//zaatu.PB(a[i]);
		//zaatu.PB(b[i]);
		for(int j=a[i]; j<b[i]; j++) zaatu.PB(j);
	}
	zaatu.PB(0);
	sort(zaatu.begin(), zaatu.end());

	cout << solve(0, 0) - 1 << endl;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
boat.cpp:29:8: 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 12 ms 2432 KB Output is correct
2 Correct 9 ms 2304 KB Output is correct
3 Correct 11 ms 2304 KB Output is correct
4 Correct 9 ms 2304 KB Output is correct
5 Correct 12 ms 2304 KB Output is correct
6 Correct 8 ms 2304 KB Output is correct
7 Correct 9 ms 2376 KB Output is correct
8 Correct 10 ms 2276 KB Output is correct
9 Correct 10 ms 2304 KB Output is correct
10 Correct 12 ms 2304 KB Output is correct
11 Correct 3 ms 2364 KB Output is correct
12 Correct 11 ms 2304 KB Output is correct
13 Correct 10 ms 2304 KB Output is correct
14 Correct 11 ms 2276 KB Output is correct
15 Correct 11 ms 2304 KB Output is correct
16 Correct 6 ms 2304 KB Output is correct
17 Correct 6 ms 2304 KB Output is correct
18 Correct 7 ms 2304 KB Output is correct
19 Correct 4 ms 2304 KB Output is correct
20 Correct 7 ms 2304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2432 KB Output is correct
2 Correct 9 ms 2304 KB Output is correct
3 Correct 11 ms 2304 KB Output is correct
4 Correct 9 ms 2304 KB Output is correct
5 Correct 12 ms 2304 KB Output is correct
6 Correct 8 ms 2304 KB Output is correct
7 Correct 9 ms 2376 KB Output is correct
8 Correct 10 ms 2276 KB Output is correct
9 Correct 10 ms 2304 KB Output is correct
10 Correct 12 ms 2304 KB Output is correct
11 Correct 3 ms 2364 KB Output is correct
12 Correct 11 ms 2304 KB Output is correct
13 Correct 10 ms 2304 KB Output is correct
14 Correct 11 ms 2276 KB Output is correct
15 Correct 11 ms 2304 KB Output is correct
16 Correct 6 ms 2304 KB Output is correct
17 Correct 6 ms 2304 KB Output is correct
18 Correct 7 ms 2304 KB Output is correct
19 Correct 4 ms 2304 KB Output is correct
20 Correct 7 ms 2304 KB Output is correct
21 Runtime error 50 ms 7548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 942 ms 525312 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2432 KB Output is correct
2 Correct 9 ms 2304 KB Output is correct
3 Correct 11 ms 2304 KB Output is correct
4 Correct 9 ms 2304 KB Output is correct
5 Correct 12 ms 2304 KB Output is correct
6 Correct 8 ms 2304 KB Output is correct
7 Correct 9 ms 2376 KB Output is correct
8 Correct 10 ms 2276 KB Output is correct
9 Correct 10 ms 2304 KB Output is correct
10 Correct 12 ms 2304 KB Output is correct
11 Correct 3 ms 2364 KB Output is correct
12 Correct 11 ms 2304 KB Output is correct
13 Correct 10 ms 2304 KB Output is correct
14 Correct 11 ms 2276 KB Output is correct
15 Correct 11 ms 2304 KB Output is correct
16 Correct 6 ms 2304 KB Output is correct
17 Correct 6 ms 2304 KB Output is correct
18 Correct 7 ms 2304 KB Output is correct
19 Correct 4 ms 2304 KB Output is correct
20 Correct 7 ms 2304 KB Output is correct
21 Runtime error 50 ms 7548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -