답안 #47447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47447 2018-05-03T07:13:26 Z mirbek01 Worst Reporter 3 (JOI18_worst_reporter3) C++17
7 / 100
1740 ms 84968 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 5e5 + 2;

long long n, q, d[N], p[N];

int main(){
      cin >> n >> q;

      int cn = 0;

      for(int i = 1; i <= n; i ++){
            cin >> d[i];
            if(d[i] == 1) cn ++;
      }

      if(cn == n){
            for(int i = 1; i <= q; i ++){
                  int t, l, r;
                  cin >> t >> l >> r;
                  int L = t - n, R = t;
                  if(l > R || L > r) {
                        cout << 0 << endl;
                        continue;
                  }
                  if(l <= L && R <= r){
                        cout << R - L + 1 << endl;
                        continue;
                  }
                  if(l <= L && L <= r){
                        cout << r - L + 1 << endl;
                        continue;
                  }
                  if(l <= R && R <= r){
                        cout << R - l + 1 << endl;
                        continue;
                  }
                  if(L <= l && r <= R){
                        cout << r - l + 1 << endl;
                        continue;
                  }
            }
            return 0;
      }

      for(int i = 2; i <= n; i ++){
            int lo = 1, hi = 1e9;
            while(hi - lo > 1){
                  int md = (lo + hi) >> 1;
                  if(d[i - 1] * md + (-(i - 1)) >= d[i])
                        hi = md;
                  else
                        lo = md;
            }
            if(d[i - 1] * lo + (-(i - 1)) >= d[i]) hi = lo;
            d[i] = d[i - 1] * hi + (-(i - 1)) - 1 - (-i);
      }

      for(int i = 1; i <= q; i ++){
            int t, l, r;
            cin >> t >> l >> r;
            p[0] = t;
            for(int j = 1; j <= n; j ++){
                  p[j] = -j;
                  int lo = 0, hi = 1000;
                  while(hi - lo > 1){
                        int md = (lo + hi) >> 1;
                        if(md * d[j] + p[j] < p[j - 1])
                              lo = md;
                        else
                              hi = md;
                  }
                  if(hi * d[j] + p[j] < p[j - 1]) lo = hi;
                  p[j] = lo * d[j] + p[j];
            }
            int cn = 0;
            for(int j = 0; j <= n; j ++)
                  if(l <= p[j] && p[j] <= r) cn ++;
            cout << cn << endl;
      }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1681 ms 7416 KB Output is correct
2 Correct 1740 ms 22820 KB Output is correct
3 Correct 1723 ms 38180 KB Output is correct
4 Correct 1676 ms 53768 KB Output is correct
5 Correct 1680 ms 69592 KB Output is correct
6 Correct 1727 ms 84968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 84968 KB Output is correct
2 Correct 48 ms 84968 KB Output is correct
3 Correct 52 ms 84968 KB Output is correct
4 Correct 49 ms 84968 KB Output is correct
5 Incorrect 48 ms 84968 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1681 ms 7416 KB Output is correct
2 Correct 1740 ms 22820 KB Output is correct
3 Correct 1723 ms 38180 KB Output is correct
4 Correct 1676 ms 53768 KB Output is correct
5 Correct 1680 ms 69592 KB Output is correct
6 Correct 1727 ms 84968 KB Output is correct
7 Correct 46 ms 84968 KB Output is correct
8 Correct 48 ms 84968 KB Output is correct
9 Correct 52 ms 84968 KB Output is correct
10 Correct 49 ms 84968 KB Output is correct
11 Incorrect 48 ms 84968 KB Output isn't correct
12 Halted 0 ms 0 KB -