A题为什么数组能过,换成Vector就WA了!!!!!!!!
A题为什么数组能过,换成Vector就WA了!!!!!!!!!
#include <bits/stdc++.h> using i64 = long long; using PII = std::pair<i64,i64>; #define int i64 #define yes std::cout << "YES\n"; #define no std::cout << "NO\n"; const int N = 1e5 + 10; int a[N],s[N],h[N],st[N],dist[N]; void solve() { int n, q, k; std::cin >> n >> q >> k; // std::vector<int> a(N),s(N),h(N),st(N),dist(N); for (int i = 1; i <= n; i ++) { int x; std::cin >> x; s[i] = s[i - 1] + x; } int idx = 0; h[0] = -1; dist[1] = 1; for (int i = 1; i <= n; i ++) { std::cin >> h[i]; if (h[i] != h[i - 1]) { dist[i] = idx = 1; } else { dist[i] = idx; } idx ++; if (dist[i] < k) { st[i] = st[i - 1]; } else { st[i] = i - k + 1; } } while (q -- ) { int x; std::cin >> x; std::cout << s[x] - s[st[x] - 1] << "\n"; } } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int T = 1; // std::cin >> T; while (T -- ) { solve(); } return 0; }