# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105725 | 2019-04-14T06:13:09 Z | Pro_ktmr | Boat (APIO16_boat) | C++14 | 889 ms | 525312 KB |
#include"bits/stdc++.h" using namespace std; #define LL long long #define REP(i, n) for(int (i)=0; (i)<(n); (i)++) #define PB push_back #define MP make_pair #define MOD 1000000007 int N; int a[500],b[500]; vector<int> zaatu; int dp[500][1002] = {}; int solve(int now, int bef){ if(now == N) return 1; if(dp[now][bef] != 0) return dp[now][bef]; LL ans = solve(now+1,bef); for(int i=max(zaatu[bef]+1,a[now]); i<b[now]; i++){ ans += solve(now+1, lower_bound(zaatu.begin(), zaatu.end(), i)-zaatu.begin()); ans %= MOD; } return dp[now][bef] = ans % MOD; } int main(){ scanf("%d", &N); for(int i=0; i<N; i++){ scanf("%d%d", a+i, b+i); b[i]++; //zaatu.PB(a[i]); //zaatu.PB(b[i]); for(int j=a[i]; j<b[i]; j++) zaatu.PB(j); } zaatu.PB(0); sort(zaatu.begin(), zaatu.end()); int dp[2][1002]; for(int i=0; i<zaatu.size(); i++){ dp[N%2][i] = 1; } for(int i=N-1; i>=0; i--){ for(int j=0; j<zaatu.size(); j++){ LL ans = dp[(i+1)%2][j]; for(int k=max(zaatu[j]+1, a[i]); k<b[i]; k++){ ans += dp[(i+1)%2][lower_bound(zaatu.begin(), zaatu.end(), k)-zaatu.begin()]; ans %= MOD; } dp[i][j] = ans; } } cout << dp[0][0] - 1 << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 889 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |