Submission #44050

#TimeUsernameProblemLanguageResultExecution timeMemory
44050wxh010910Worst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
990 ms11568 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back #define Debug(...) fprintf(stderr, __VA_ARGS__) typedef long long LL; typedef long double LD; typedef unsigned int uint; typedef pair <int, int> pii; typedef unsigned long long uLL; template <typename T> inline void Read(T &x) { char c = getchar(); bool f = false; for (x = 0; !isdigit(c); c = getchar()) { if (c == '-') { f = true; } } for (; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } if (f) { x = -x; } } template <typename T> inline bool CheckMax(T &a, const T &b) { return a < b ? a = b, true : false; } template <typename T> inline bool CheckMin(T &a, const T &b) { return a > b ? a = b, true : false; } const int N = 500005; LL a[N], b[N]; int n, m; inline int Solve(int t, int p) { int ret = n + 1, l = 0, r = n; while (l <= r) { int mid = l + r >> 1; if (t / b[mid] * a[mid] - mid <= p) { ret = mid, r = mid - 1; } else { l = mid + 1; } } return ret; } int main() { #ifdef wxh010910 freopen("d.in", "r", stdin); #endif Read(n), Read(m), a[0] = b[0] = 1; for (int i = 1; i <= n; ++i) { Read(a[i]); a[i] = (a[i] + a[i - 1] - 1) / a[i - 1] * a[i - 1]; b[i] = b[i - 1] * (a[i] / a[i - 1]); } for (int i = 1, t, l, r; i <= m; ++i) { Read(t), Read(l), Read(r); printf("%d\n", Solve(t, l - 1) - Solve(t, r)); } #ifdef wxh010910 Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC); #endif return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int Solve(int, int)':
worst_reporter3.cpp:49:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...