Submission #47443

# Submission time Handle Problem Language Result Execution time Memory
47443 2018-05-03T06:36:41 Z Just_Solve_The_Problem Worst Reporter 3 (JOI18_worst_reporter3) C++11
12 / 100
2000 ms 10104 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define random rand() ^ (rand() << 5)

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;

int n, q;
int d[N];
pii ar[N];
ll pos[N];

main() {
  scanf("%d %d", &n, &q);
  ar[0] = {1, 1};
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    ar[i].sc = (d[i] + ar[i - 1].sc - 1) / ar[i - 1].sc * ar[i - 1].fr;
    ar[i].fr = (ar[i].sc / ar[i - 1].fr * ar[i - 1].sc + (-(i - 1))) - 1 - (-i);
  }
  while (q--) {
    int t, l, r;
    scanf("%d %d %d", &t, &l, &r);
    for (int i = 0; i <= n; i++) {
      pos[i] = t / ar[i].sc * ar[i].fr + (-i);
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
      if (pos[i] >= l && pos[i] <= r) {
        ans++;
      }
    }
    printf("%d\n", ans);
  }
}

Compilation message

worst_reporter3.cpp:27:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &q);
   ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &d[i]);
     ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &t, &l, &r);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 10104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 10104 KB Output is correct
2 Correct 7 ms 10104 KB Output is correct
3 Correct 8 ms 10104 KB Output is correct
4 Correct 9 ms 10104 KB Output is correct
5 Correct 8 ms 10104 KB Output is correct
6 Correct 11 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 10104 KB Time limit exceeded
2 Halted 0 ms 0 KB -