#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> ans(n + 5); int j = 1; for (int i = 1; i <= n + 4; i += 2) { ans[i] = j; j++; } j = n; for (int i = 2; i <= n + 4; i += 2) { ans[i] = j; j--; } for (int i = n; i >= 1; 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; string s; cin >> s; int cnt = 0, ans = 0; bool f = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') { cnt++; } else { if (!f) { ans++; ans += (cnt + 1) / 3; cnt = 0; f = 1; continue; } ans++; ans += cnt / 3; cnt = 0; } } if (!f) { ans += (cnt + 2) / 3; cout << ans << "\n"; return ; } ans += (cnt + 1) / 3; cout << ans << "\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), b(n + 5); for (int i = 1; i <= n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b.begin() + 1, b.begin() + 1 + n); int mn = b[1]; int mx = b[n]; int k = 1e15; bool f = 0; int x = 0; for (int i = 1; i <= n; i++) { if (a[i] != b[i]) { f = 1; k = min(max(abs(mn - b[i]), abs(mx - b[i])), k); } } if (!f) { cout << "-1\n"; return ; } cout << k << "\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 x, y; cin >> x >> y; if ((x & y) == 0) { cout << x << " " << y << "\n"; return ; } int ans1 = 0, ans2 = 0; bool f = 0; if (x > y) { f = 1; swap(x, y); } int p = 0, q = 0; bool ff = 0, fff = 0;
auto cmp = [&] (int a, int b) -> bool { returnabs(a - x) < abs(b - x); }; int mn = 1e18;