#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007LL
#define ff first
#define ss second
int a[505], b[505];
ll x[2005];
ll val[2005];
map<int, int> comp;
vector<pair<ll, int > > v;
set<int> in;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
in.insert(0);
for(int i = 1; i <= n; i++){
cin>>a[i]>>b[i];
in.insert(a[i]);
in.insert(b[i]);
in.insert(b[i] + 1);
}
int oll = -1;
for(int t : in){
x[++oll] = t;
comp[t] = oll;
}
val[0] = 1;
for(int i = 1; i <= n; i++){
int l = comp[a[i]];
int r = comp[b[i]];
v.clear();
int j;
ll pre = 0;
for(j = 0; j < l; j++){
pre = (pre + (x[j + 1] - x[j]) * val[j]) % MOD;
}
for(; j <= r; j++){
val[j] += pre;
pre = val[j];
}
}
ll res = -1;
for(int i = 0; i < oll; i++){
res = (res + (x[i + 1] - x[i]) * val[i]) % MOD;
}
cout<<res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |