Submission #319255

#TimeUsernameProblemLanguageResultExecution timeMemory
319255mohamedsobhi777Worst Reporter 3 (JOI18_worst_reporter3)C++14
0 / 100
615 ms36324 KiB
#include <bits/stdc++.h> #pragma GCC optimize("-Ofast") //#pragma GCC optimize("trapv") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-funroll-loops") #define I inline void #define S struct #define vi vector<int> #define vii vector<pair<int, int>> #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; using ll = long long; using ld = long double; const int N = 5e5 + 7, mod = 1e9 + 7; const ll inf = 2e18; // How interesting! int n, m; int a[N], ans[N]; vector<pair<pii, pii>> v; vector<int> mov[N]; ll per[N]; bool f(int i, int t, int l, int r) { int p = per[i]; int pos = -(i + 1); int d = t / p; pos += p * d; return pos >= l && pos <= r; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen("in.in", "r", stdin); cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> a[i]; } per[0] = a[0]; for (int i = 1; i < n; ++i) per[i] = ceil(1.0 * a[i] / per[i - 1]) * per[i - 1]; for (int i = 0; i < m; ++i) { int x, y, z; cin >> x >> y >> z; int l = 0, r = n - 1; int ans1 = 0, ans2 = -1; int k = 0; while (l <= r) { int mid = (l + r) >> 1; if (f(mid, x, y, z)) { ans1 = mid; r = mid - 1; } else l = mid + 1; } l = 0, r = n - 1; while (l <= r) { int mid = (l + r) >> 1; if (f(mid, x, y, z)) { ans2 = mid; l = mid + 1; } else r = mid - 1; } cout << ans2 - ans1 + 1 + (x >= y && x <= z) << "\n"; } return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:61:21: warning: unused variable 'k' [-Wunused-variable]
   61 |                 int k = 0;
      |                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...