답안 #642913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642913 2022-09-20T18:56:02 Z valerikk Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
2000 ms 6456 KB
#include <cstdio>

#define MAXN 500005
#define MAXT 1000000001

int N, Q;
int D[MAXN];
int W[MAXN], C[MAXN];

int count(int T, int L) {
  int res = (T >= L);

  int X = T;
  for (int i = 1; i <= N; ++i) {
    int r = T % C[i];
    T /= C[i];
      
    X -= r * W[i] + 1;
    res += (X >= L);
  }
  
  return res;
}

int main() {
  scanf("%d%d", &N, &Q);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &D[i]);
  }

  W[1] = 1;
  C[1] = D[1];
  for (int i = 2; i <= N; ++i) {
    W[i] = C[i - 1] * W[i - 1];
    C[i] = (D[i] + W[i] - 1) / W[i];
  }

  while (Q--) {
    int T, L, R;
    scanf("%d%d%d", &T, &L, &R);
    printf("%d\n", count(T, L) - count(T, R + 1));
  }
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%d", &N, &Q);
      |   ~~~~~^~~~~~~~~~~~~~~~
worst_reporter3.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d", &D[i]);
      |     ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     scanf("%d%d%d", &T, &L, &R);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2078 ms 6456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 212 KB Output is correct
2 Correct 10 ms 332 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 10 ms 212 KB Output is correct
5 Correct 10 ms 212 KB Output is correct
6 Correct 10 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2078 ms 6456 KB Time limit exceeded
2 Halted 0 ms 0 KB -