# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
549738 | 2022-04-16T11:37:26 Z | krit3379 | Boat (APIO16_boat) | C++17 | 836 ms | 524288 KB |
#include<bits/stdc++.h> using namespace std; #define N 505 long long dp[N][N][N],a[N],b[N],l[2*N],r[2*N],ans,mod=1e9+7; vector<long long> v; // num -> at i-th scholl -> with up_val int main(){ int n,i,j,k; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lld %lld",&a[i],&b[i]),v.push_back(a[i]),v.push_back(b[i]); v.push_back(-1); sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end())-v.begin()); v.push_back(v.back()+1); for(i=1;i<=n;i++){ l[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin(); r[i]=lower_bound(v.begin(),v.end(),b[i])-v.begin(); } for(i=0;i<=n;i++)for(j=0;j<=n;j++)dp[0][i][j]=1; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ for(k=1;k<v.size();k++){ if(l[j]<=k&&k<=r[j])dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-1][k-1]*(v[k+1]-v[k]))%mod; dp[i][j][k]=(dp[i][j][k]+dp[i][j][k-1]+dp[i][j-1][k]-dp[i][j-1][k-1]+mod)%mod; } } ans=(ans+dp[i][n][v.size()-1])%mod; } printf("%lld",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 836 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 836 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 40620 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 836 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |