Submission #1037197

#TimeUsernameProblemLanguageResultExecution timeMemory
1037197Halym2007Boat (APIO16_boat)C++17
0 / 100
1499 ms524288 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e2 + 5; #define ll long long ll a[N], b[N]; int dp[N], mod = 1e9 + 7, n; map <ll, int> m; int main () { // freopen ("input.txt", "r", stdin); ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i] >> b[i]; } for (int i = 1; i <= n; ++i) { for (int j = a[i]; j <= b[i]; ++j) { m[j] = 1; } } int san = 0; for (auto i : m) { m[i.first] = ++san; } for (int i = 1; i <= n; ++i) { a[i] = m[a[i]]; b[i] = m[b[i]]; } dp[0] = 1; for (int i = 1; i <= n; ++i) { // if (i == 2) { // return cout << dp[2], 0; // } for (int j = b[i]; j >= a[i]; j--) { int sum = 0; for (int l = 0; l < j; ++l) { sum += dp[l]; sum %= mod; } dp[j] += sum; dp[j] %= mod; } } int jog = 0; for (int i = 1; i <= san; ++i) { jog += dp[i]; // cout << i << " " << dp[i] << "\n"; } cout << jog; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...