제출 #105723

#제출 시각아이디문제언어결과실행 시간메모리
105723Pro_ktmrBoat (APIO16_boat)C++14
9 / 100
1033 ms525312 KiB
#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;

LL dp[500][1002] = {};
LL solve(int now, int bef){
	if(now == N) return 1LL;
	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;
}

컴파일 시 표준 에러 (stderr) 메시지

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);
   ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...