Submission #739430

#TimeUsernameProblemLanguageResultExecution timeMemory
739430Alihan_8Boat (APIO16_boat)C++17
9 / 100
4 ms2288 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...