답안 #127729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127729 2019-07-10T04:04:42 Z RockyB Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
2000 ms 80644 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;

vector <int> a;
void move() {
  a.back()++;
  per(i, n - 1, 0) {
    if (a[i + 1] - a[i] > d[n - i]) a[i] = a[i + 1] - 1;
  }
}
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);
  }
  per(i, n, 1) a.pb(-i);
  a.pb(0);
  for (auto it : off) {
    while (a.back() < it.f) move();
    for (auto i : it.s) {
      ans[i] = upper_bound(all(a), r[i]) - lower_bound(all(a), l[i]);
    }
  }
  rep(i, 1, q) {
    cout << ans[i] << nl;
  }

  ioi
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2036 ms 80644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 4 ms 552 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 4 ms 520 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2036 ms 80644 KB Time limit exceeded
2 Halted 0 ms 0 KB -