Submission #124069

# Submission time Handle Problem Language Result Execution time Memory
124069 2019-07-02T13:10:43 Z nvmdava Boat (APIO16_boat) C++17
9 / 100
6 ms 632 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);
   in.insert(1);
   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;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 504 KB Output is correct
15 Correct 4 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 504 KB Output is correct
15 Correct 4 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Incorrect 6 ms 504 KB Output isn't correct
22 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 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 504 KB Output is correct
15 Correct 4 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Incorrect 6 ms 504 KB Output isn't correct
22 Halted 0 ms 0 KB -