Submission #220210

#TimeUsernameProblemLanguageResultExecution timeMemory
220210patrikpavic2Worst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
582 ms25648 KiB
#include <cstdio> #include <cstring> #include <vector> #include <algorithm> #define X first #define Y second #define PB push_back using namespace std; typedef long long ll; const int N = 5e5 + 500; ll D[N]; int n, q, nxt[N]; int kolko(ll T,ll L,ll R){ ll tren = T; int ans = 0; for(int i = 0;i <= n;i = nxt[i]){ ll R2 = tren * D[i] - i, L2 = tren * D[i] - nxt[i] + 1; if(max(L, L2) <= min(R, R2)) ans += min(R, R2) - max(L, L2) + 1; if(nxt[i] <= n) tren = tren / (D[nxt[i]] / D[i]); if(!tren) break; } return ans; } int main(){ scanf("%d%d", &n, &q); D[0] = 1; for(int i = 1;i <= n;i++){ scanf("%lld", D + i); if(D[i] < D[i - 1]) D[i] = D[i - 1]; else if(D[i] % D[i - 1]) D[i] += D[i - 1] - D[i] % D[i - 1]; } int lst = 0; for(int i = 1;i <= n;i++){ if(D[i] != D[lst]){ nxt[lst] = i; lst = i; } } nxt[lst] = n + 1; for(;q--;){ ll A, B, C; scanf("%lld%lld%lld", &A, &B, &C); printf("%d\n", kolko(A, B, C)); } return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:35:7: 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:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", D + i);
   ~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:53:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll A, B, C; scanf("%lld%lld%lld", &A, &B, &C);
               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...