# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
69286 |
2018-08-20T11:19:49 Z |
FedericoS |
Boat (APIO16_boat) |
C++14 |
|
2000 ms |
27284 KB |
#include <iostream>
#include <unordered_map>
#include <map>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
ll M=1000000007;
int N;
ll X[505],Y[505];
map<ll,ll> S;
map<pll,ll> DP;
ll ans;
unordered_map<ll,ll> R;
ll query(ll k, ll l, ll r, ll a, ll b){
if(b<l or r<a) return 0;
if(a<=l and r<=b) return R[k];
ll m=(l+r)/2;
return (query(2*k,l,m,a,b)+query(2*k+1,m+1,r,a,b))%M;
}
void insert(ll k, ll l, ll r, ll a, ll b){
if(l==r) R[k]=(R[k]+b)%M;
else{
ll m=(l+r)/2;
if(a<=m)
insert(2*k,l,m,a,b);
else
insert(2*k+1,m+1,r,a,b);
R[k]=(R[2*k]+R[2*k+1])%M;
}
}
ll somma(ll a){
return query(1,0,M,a,M-1);
}
void aggiungi(ll a, ll b){
insert(1,0,M,a,b);
}
int main(){
cin>>N;
for(int i=0;i<N;i++)
cin>>X[i]>>Y[i];
while(clock()<N*1e4);
for(int i=N-1;i>=0;i--)
for(ll j=X[i];j<=Y[i];j++){
DP[{i,j}]=(somma(j+1)+1)%M;
aggiungi(j,DP[{i,j}]);
ans=(ans+DP[{i,j}])%M;
//cout<<i<<" "<<j<<" "<<DP[{i,j}]<<endl;
}
//for(int i=0;i<10;i++)cout<<i<<" "<<S[i]<<endl;
cout<<ans;
}
/*
3
1 1
2 2
3 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2066 ms |
376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2066 ms |
376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2069 ms |
27284 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2066 ms |
376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |