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 河南

相关推荐

不愿透露姓名的神秘牛友
07-10 15:58
投个小米提前批试试水,先投一个岗位看看形势,不行就再沉淀一下投第二个岗位,莫辜负
Java抽象带篮子:我嘞个骚刚,已经开始研发6g了吗
投递小米集团等公司7个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-11 17:10
什么素质,我请问呢,要掉小珍珠了。。。又憋屈又生气
Steven267:这不喷回去?花钱是大爷,记住这个道理
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务