답안 #127734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127734 2019-07-10T04:20:29 Z RockyB Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
2000 ms 67716 KB
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

#define rep(a, b, c) for (int a = (b); (a) <= (c); ++a)
#define per(a, b, c) for (int a = (b); (a) >= (c); --a) 

#define nl '\n'
#define ioi exit(0);

using namespace std;

const int MAX_N = (int)5e5 + 7;

int n, q;
int d[MAX_N], l[MAX_N], r[MAX_N], t[MAX_N], ans[MAX_N];

map <int, vector <int> > off;

void solve(int T, vector <int> &qr) {
  vector <int> a;
  a.pb(T);
  rep(i, 1, n) {
    int p = -i;
    if (a.back() + i > d[i]) p = a.back() - 1;
    a.pb(p);
  }
  reverse(all(a));
  /* for (auto it : a) cerr << it << ' ';
  cerr << nl; */
  for (auto it : qr) {
    int L = l[it], R = r[it];
    ans[it] = upper_bound(all(a), R) - lower_bound(all(a), L);
  }
}
int main() {
  #ifdef IOI
    freopen ("in.txt", "r", stdin);
  #endif
  ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  rep(i, 1, n) cin >> d[i];
  rep(i, 1, q) {
    cin >> t[i] >> l[i] >> r[i];
    off[t[i]].pb(i);
  }

  for (auto it : off) {
    solve(it.f, it.s);  
  }

  rep(i, 1, q) {
    cout << ans[i] << nl;
  }

  ioi
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 67716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 67716 KB Time limit exceeded
2 Halted 0 ms 0 KB -