# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739430 |
2023-05-10T12:52:51 Z |
Alihan_8 |
Boat (APIO16_boat) |
C++17 |
|
4 ms |
2288 KB |
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
#define int long long
template <class _T>
bool chmin(_T &x, const _T &y){
bool flag = false;
if ( x > y ){
x = y; flag |= true;
}
return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool flag = false;
if ( x < y ){
x = y; flag |= true;
}
return flag;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
vector <int> a(n), b(n), pos;
for ( int i = 0; i < n; i++ ){
cin >> a[i] >> b[i];
pos.pb(a[i]); pos.pb(b[i]);
}
sort(all(pos));
pos.resize(unique(all(pos)) - pos.begin());
auto id = [&](int x){
return lower_bound(all(pos), x) - pos.begin() + 1;
};
const int Mod = 1e9 + 7;
auto add = [&](int &x, const int &y){
x = (x + y) % Mod;
if ( x < 0 ) x += Mod;
};
vector <vector<int>> dp(n + 1, vector <int> (n + 1));
dp[0][0] = 1;
for ( int i = 1; i <= n; i++ ){
int v = id(a[i - 1]);
for ( int j = 0; j <= n; j++ ){
dp[i][j] = dp[i - 1][j];
}
for ( int k = 0; k < v; k++ ){
add(dp[i][v], dp[i - 1][k]);
}
}
int cnt = 0;
for ( int i = 1; i <= n; i++ ){
add(cnt, dp[n][i]);
}
cout << cnt;
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2260 KB |
Output is correct |
2 |
Correct |
3 ms |
2248 KB |
Output is correct |
3 |
Correct |
3 ms |
2260 KB |
Output is correct |
4 |
Correct |
3 ms |
2260 KB |
Output is correct |
5 |
Correct |
3 ms |
2256 KB |
Output is correct |
6 |
Correct |
4 ms |
2288 KB |
Output is correct |
7 |
Correct |
3 ms |
2260 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
3 ms |
2260 KB |
Output is correct |
10 |
Correct |
3 ms |
2252 KB |
Output is correct |
11 |
Correct |
3 ms |
2260 KB |
Output is correct |
12 |
Correct |
3 ms |
2260 KB |
Output is correct |
13 |
Correct |
3 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2260 KB |
Output is correct |
15 |
Correct |
3 ms |
2252 KB |
Output is correct |
16 |
Correct |
2 ms |
2260 KB |
Output is correct |
17 |
Correct |
2 ms |
2248 KB |
Output is correct |
18 |
Correct |
2 ms |
2260 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2260 KB |
Output is correct |
2 |
Correct |
3 ms |
2248 KB |
Output is correct |
3 |
Correct |
3 ms |
2260 KB |
Output is correct |
4 |
Correct |
3 ms |
2260 KB |
Output is correct |
5 |
Correct |
3 ms |
2256 KB |
Output is correct |
6 |
Correct |
4 ms |
2288 KB |
Output is correct |
7 |
Correct |
3 ms |
2260 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
3 ms |
2260 KB |
Output is correct |
10 |
Correct |
3 ms |
2252 KB |
Output is correct |
11 |
Correct |
3 ms |
2260 KB |
Output is correct |
12 |
Correct |
3 ms |
2260 KB |
Output is correct |
13 |
Correct |
3 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2260 KB |
Output is correct |
15 |
Correct |
3 ms |
2252 KB |
Output is correct |
16 |
Correct |
2 ms |
2260 KB |
Output is correct |
17 |
Correct |
2 ms |
2248 KB |
Output is correct |
18 |
Correct |
2 ms |
2260 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2260 KB |
Output is correct |
21 |
Incorrect |
3 ms |
2260 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2260 KB |
Output is correct |
2 |
Correct |
3 ms |
2248 KB |
Output is correct |
3 |
Correct |
3 ms |
2260 KB |
Output is correct |
4 |
Correct |
3 ms |
2260 KB |
Output is correct |
5 |
Correct |
3 ms |
2256 KB |
Output is correct |
6 |
Correct |
4 ms |
2288 KB |
Output is correct |
7 |
Correct |
3 ms |
2260 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
3 ms |
2260 KB |
Output is correct |
10 |
Correct |
3 ms |
2252 KB |
Output is correct |
11 |
Correct |
3 ms |
2260 KB |
Output is correct |
12 |
Correct |
3 ms |
2260 KB |
Output is correct |
13 |
Correct |
3 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2260 KB |
Output is correct |
15 |
Correct |
3 ms |
2252 KB |
Output is correct |
16 |
Correct |
2 ms |
2260 KB |
Output is correct |
17 |
Correct |
2 ms |
2248 KB |
Output is correct |
18 |
Correct |
2 ms |
2260 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2260 KB |
Output is correct |
21 |
Incorrect |
3 ms |
2260 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |