# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
792835 | IvanJ | Boat (APIO16_boat) | C++17 | 10 ms | 16340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int maxn = 505;
const int MOD = 1e9 + 7;
int add(int x, int y) {x += y;if(x >= MOD) x -= MOD;return x;}
int sub(int x, int y) {x -= y;if(x < 0) x += MOD;return x;}
int n;
int a[maxn], b[maxn];
int main() {
scanf("%d", &n);
for(int i = 0;i < n;i++)
scanf("%d%d", a + i, b + i);
vector<int> dp(1e6 + 1, 0), pref(1e6 + 1, 0);
int maxi = 0;
for(int i = 0;i < n;i++) {
maxi = max(maxi, b[i]);
for(int j = a[i];j <= b[i];j++) {
if(i == 0) dp[j] = 1;
else {
if(j - 1 >= a[i - 1]) {
int sum = pref[j - 1];
dp[j] = add(dp[j], sum);
}
}
}
if(i == 0) dp[0] = 1;
//for(int j = 0;j <= maxi;j++) cout << dp[j] << " ";
//cout << "\n";
pref[0] = dp[0];
for(int j = 1;j <= maxi;j++)
pref[j] = add(pref[j - 1], dp[j]);
}
printf("%d\n", sub(pref[maxi], (n > 1) ? dp[0] : 0));
return 0;
}
컴파일 시 표준 에러 (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... |