# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
124065 |
2019-07-02T12:53:20 Z |
nvmdava |
Boat (APIO16_boat) |
C++17 |
|
4 ms |
376 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007LL
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;
val[j] %= MOD;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |