Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
36046 a+qazolite 【S】T1 C++ 解答错误 90 174 MS 8056 KB 1172 2025-02-07 14:54:45

Tests(9/10):


#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2e5 + 5; int n, Q; ll a[N]; ll l, r; struct ask { ll q, x, s, t; } q[N]; ll check(ll x) { for (int i = 1; i <= Q; i++) { if (q[i].q == 1 && x >= q[i].x) x = q[i].t * (x + q[i].s); else if (q[i].q == 2 && x <= q[i].x) x = (x - q[i].s) / q[i].t; } return x; } int main() { cin >> n >> Q >> l >> r; ll L = 0x3f3f3f3f, R = -0x3f3f3f3f; for (int i = 1; i <= n; i++) { scanf("%lld", a + i); L = min(L, a[i]), R = max(R, a[i]); } for (int i = 1; i <= Q; i++) scanf("%lld%lld%lld%lld", &q[i].q, &q[i].x, &q[i].s, &q[i].t); ll x = L, y = R, res1 = 0, res2 = 0; while (x <= y) { ll mid = (x + y) >> 1; if (check(mid) >= l) { res1 = mid; y = mid - 1; } else x = mid + 1; } x = L, y = R; while (x <= y) { ll mid = (x + y) >> 1; if (check(mid) <= r) { res2 = mid; x = mid + 1; } else y = mid - 1; } // cout << res1 << ' ' << res2 << endl; int cnt = 0; for (int i = 1; i <= n; i++) if (res1 <= a[i] && a[i] <= res2) cnt++; cout << cnt << endl; return 0; }


测评信息: