Submission #124067

# Submission time Handle Problem Language Result Execution time Memory
124067 2019-07-02T13:04:05 Z nvmdava Boat (APIO16_boat) C++17
0 / 100
4 ms 504 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;
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(auto& 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]];
      int j;
      ll pre = 0;
      for(j = 0; j < l; j++){
         pre = (pre + (x[j + 1] - x[j]) * val[j] % MOD) % 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) % MOD;
   }
   cout<<(res + MOD) % MOD;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 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 504 KB Output isn't correct
2 Halted 0 ms 0 KB -