Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
35990 andy2025 【S】T1 C++ 通过 100 143 MS 8084 KB 1061 2025-02-07 13:43:22

Tests(10/10):


#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; #define ll long long int n,q; ll L,R,a[N]; struct node { ll Q,x,s,t; } opt[N]; bool check(int pos,ll v) { ll st = a[pos]; for(int i = 1;i <= q;i++) { if(opt[i].Q == 1) { if(st >= opt[i].x) st = opt[i].t * (opt[i].s + st); } else { if(st <= opt[i].x) st = (st - opt[i].s) / opt[i].t; } } return st <= v; } int solve(ll val) { int l = 1,r = n,ans = 0; while(l <= r) { int mid = (l + r) >> 1; if(check(mid,val)) l = mid + 1,ans = mid; else r = mid - 1; } return ans; } int main() { //freopen("arithmetic.in","r",stdin); //freopen("arithmetic.out","w",stdout); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q >> L >> R; for(int i = 1;i <= n;i++) cin >> a[i]; sort(a + 1,a + n + 1); for(int i = 1;i <= q;i++) cin >> opt[i].Q >> opt[i].x >> opt[i].s >> opt[i].t; cout << solve(R) - solve(L - 1); return 0; }


测评信息: