# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
523726 |
2022-02-08T05:10:47 Z |
vonatlus |
Boat (APIO16_boat) |
C++17 |
|
1 ms |
204 KB |
/// adil sultanov | vonat1us
#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
void fin() {
#ifdef AM
freopen(".in", "r", stdin);
#endif
}
const bool flag = 0;
const int N = 1e5+10;
int dp[N][2];
int add(int a, int b) {
a += b;
if (a >= MOD) a -= MOD;
return a;
}
void ma1n() {
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
if (n == 1) {
cout << b[0]-a[0]+1, exit(0);
}
dp[0][0] = dp[0][1] = 1;
for (int i = 1; i < n; ++i) {
dp[i][0] = add(dp[i-1][1], dp[i-1][0]);
for (int j = 0; j < i; ++j) {
if (a[j] < a[i]) {
dp[i][1] = add(dp[i][1], dp[j][1]);
}
}
}
cout << add(dp[n-1][0], dp[n-1][1]);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr), fin();
int ts = 1;
if (flag) {
cin >> ts;
}
while (ts--) {
ma1n();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |