# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
124209 | AyaBenSaad | Boat (APIO16_boat) | C++14 | 2059 ms | 8392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int M = 5e2 + 2;
const int N = 1e2 + 6;
int n, a[M], b[M];
set <int> s;
vector <int> v;
map <pair <int, int>, int> dp;
int solve (int id, int last) {
if (id >= n) return (last != 0 ? 1 : 0);
int &ret = dp[{id,last}];
if (ret != 0) return ret;
ret = solve(id+1, last);
for (int i = max (a[id], last+1); i <= b[id]; i++) {
ret = (1ll*ret + 1ll*solve (id+1, i)) % MOD;
}
return ret;
}
int main () {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &a[i], &b[i]);
s.insert (a[i]);
s.insert (b[i]);
}
for (int i : s) {
v.push_back(i);
}
printf("%d\n", solve (0, 0));
}
//1 2
//2 3
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |