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; 
}

全部评论
先贴出来你的代码啊......
点赞 回复 分享
发布于 2023-07-23 21:33 河南

相关推荐

这都要4499吗,现在华为od门槛这么高了吗?
北海勇将王冲:od 不是学历够,能过机考就能进吗?八股好像都不怎么用背
点赞 评论 收藏
分享
zhiyog:哈哈哈,其实是津巴布韦币
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务