Submission #124065

#TimeUsernameProblemLanguageResultExecution timeMemory
124065nvmdavaBoat (APIO16_boat)C++17
0 / 100
4 ms376 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...