제출 #636840

#제출 시각아이디문제언어결과실행 시간메모리
636840TobBoat (APIO16_boat)C++14
9 / 100
3 ms980 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; ll nxt() {ll num; cin >> num; return num;} const int N = 507; const ll mod = 1e9 + 7; ll n; ll arr[N]; vector <int> adj[N]; ll dp[N]; ll Mod(ll x) { return (x < mod) ? x : x % mod; } ll DP(int x) { if (dp[x]) return dp[x]; for (auto it : adj[x]) { dp[x] = Mod(dp[x] + DP(it)); } dp[x] = Mod(dp[x]+1); return dp[x]; } int main () { cin >> n; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; arr[i] = a; } arr[n] = 1e18; for (int i = n; i; i--) { for (int j = i-1; j >= 0; j--) { if (arr[i] > arr[j]) adj[i].pb(j); } } cout << DP(n)-1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...