Submission #1029369

#TimeUsernameProblemLanguageResultExecution timeMemory
1029369VMaksimoski008Boat (APIO16_boat)C++17
9 / 100
1 ms604 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; //subtask 1 - all different (kolku ima rastecki podnizi) signed main() { int n; cin >> n; bool sub1 = 1; vector<int> a(n+1), b(n+1); for(int i=1; i<=n; i++) { cin >> a[i] >> b[i]; if(a[i] < b[i]) sub1 = 0; } if(sub1) { vector<ll> dp(n+1, 1); for(int i=2; i<=n; i++) for(int j=1; j<i; j++) if(a[j] < a[i]) dp[i] = (dp[i] + dp[j]) % mod; ll ans = 0; for(int i=1; i<=n; i++) ans = (ans + dp[i]) % mod; cout << ans << '\n'; return 0; } 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...