#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n, h, l; cin >> n >> h >> l; vector<int> a(n + 5); int num = 0, cnt = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] <= min(h, l)) num++; else { if (a[i] <= max(h, l)) cnt++; } } if (cnt <= num) { cout << (num + cnt) / 2 << "\n"; return ; } cout << num << "\n";
#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n, x; cin >> n >> x; vector<arr3> a(n + 5); bool f = 0; int num = 0; int mx = 0, pos = -1; for (int i = 1; i <= n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2]; if (a[i][0] * a[i][1] > a[i][2]) f = 1; num += (a[i][0] * (a[i][1] - 1)); mx = max(mx, a[i][0] * a[i][1] - a[i][2]); } if (num >= x) { cout << "0\n"; return ; } if (!f) { cout << "-1\n"; return ; } if ((x - num) % mx) cout << (x - num) / mx + 1 << "\n"; else cout << (x - num) / mx << "\n"; }
#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n; cin >> n; vector<int> a(n + 5); vector<int> ans(n + 5); ans[n] = 1; set<int> st; for (int i = 2; i <= n; i++) st.insert(i); for (int i = n - 1; i >= 2; i--) { ans[i] = ans[n] ^ i; st.erase(ans[i]); } ans[1] = *st.begin(); for (int i = 1; i <= n; i++) { cout << ans[i] << " "; } cout << "\n"; }
#include<bits/stdc++.h> #define int long long usingnamespace std; using ll = longlong; using arr2 = array<int, 2>; using arr3 = array<int, 3>; constint N = (int)2e5 + 9; constint M = (int)1e5 + 9; constint mod = 998244353;
voidsolve(){ int n; cin >> n; vector<int> a(n + 5); vector<int> ans(n + 5); if (n % 2) { ans[n] = 1; set<int> st; for (int i = 2; i <= n; i++) st.insert(i); for (int i = n - 1; i >= 2; i--) { ans[i] = ans[n] ^ i; st.erase(ans[i]); } ans[1] = *st.begin(); for (int i = 1; i <= n; i++) { cout << ans[i] << " "; } cout << "\n"; return ; } ans[n] = 1; set<int> st; vector<bool> vis(n * 2 + 5); vis[1] = (1 ^ n); bool ff = 0; for (int i = 2; i <= n; i++) st.insert(i); for (int i = n - 1; i >= 2; i--) { if (!ff && vis[i]) { ans[i] = n; ff = 1; } else { ans[i] = ans[n] ^ i; vis[ans[i] ^ n] = 1; } st.erase(ans[i]); } ans[1] = *st.begin(); if (!ff) { cout << "-1\n"; return ; } for (int i = 1; i <= n; i++) { cout << ans[i] << " "; } cout << "\n"; }