Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
35975 a+qazolite 【S】T1 C++ 运行出错 0 0 MS 256 KB 1252 2025-02-07 12:43:27

Tests(0/10):


#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2e5 + 5; int n, Q, 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() { freopen("arithmetic.in", "r", stdin); freopen("arithmetic.out", "w", stdout); cin >> n >> Q >> l >> r; int L = 0x3f3f3f3f, R = -0x3f3f3f3f; for (int i = 1; i <= n; i++) { scanf("%d", 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); int x = L, y = R, res1 = 0, res2 = 0; while (x <= y) { int mid = (x + y) >> 1; if (check(mid) >= l) { res1 = mid; y = mid - 1; } else x = mid + 1; } x = L, y = R; while (x <= y) { int 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; }


测评信息: