CSES Subarray Sums II
// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#define Debug(x...) _debug_print_format(#x, x);
std::ifstream terminal("/dev/tty");
#define PP cerr<<"\033[1;30mpause...\e[0m",terminal.ignore();
#else
#define debug(x...)
#define Debug(x...)
#define PP
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define FIND(a, x) ((find(a.begin(),a.end(),(x))!=a.end())?1:0)
#define cmin(x,...) x=min({(x),__VA_ARGS__})
#define cmax(x,...) x=max({(x),__VA_ARGS__})
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define NaN (int)(0x8b88e1d0595d51d1)
#define double long double
#define int long long
#define uint unsigned long long
#define MAXN 200010

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n, k; cin >> n >> k;
    map<int, int> m;
    m[0] = 1;
    int sum = 0, ans = 0;
    rep(i, 0, n) {
        int x; cin >> x;
        sum += x;
        ans += m[sum - k];
        m[sum]++;
    }
    cout << ans << endl;

    return 0;
}

Comments

  1. 11 months ago
    2025-12-06 2:41:14

    Hey folks, anyone tried their luck with 777uaelottery? Dreaming of getting a big win. For those interested, go check out 777uaelottery!

  2. 11 months ago
    2025-12-19 13:55:55

    Signed up for W88 through linkvaow88 net. Smooth process, got my bonus and I’m ready to roll. Give it a shot: đăng ký w88 linkvaow88 net

  3. 10 months ago
    2025-12-29 6:24:18

    Alright folks, I’m giving bk8bet89 a try. Heard some good things about their customer support, so I’m hoping that’s true! The promos look decent too. Worth checking out: bk8bet89

  4. 2 months ago
    2026-9-08 17:59:32

    Really impressed with the security and speed of bitpkrgame. Everything feels professional and the gaming experience is top notch. Definitely my new go-to site.

  5. 1 month ago
    2026-9-21 10:14:29

    [4641]Sportsbook login ph | Legit online slots at casino sa GCash,Mag-sportsbook login ph na para sa mabilis na access. Download sportsbook app at subukan ang legit online slots gcash. Alamin din kung paano maglaro ng baccarat. visit: sportsbook

  6. 3 weeks ago
    2026-10-10 1:51:30

    Found this site through a friend and I am glad I did. The game variety is huge and the wins are consistent. Much love to vnf1685!

  7. 3 weeks ago
    2026-10-11 10:59:44

    [2159]Wildzy লগইন এবং অ্যাপ ডাউনলোড – বিকাশ দিয়ে অনলাইন ক্যাসিনো,wildzy লগইন করুন এবং সেরা অনলাইন স্লট গেমস উপভোগ করুন। বিকাশ দিয়ে অনলাইন ক্যাসিনো গেম খেলতে আজই wildzy app download করে শুরু করুন। visit: wildzy

  8. 3 weeks ago
    2026-10-12 11:18:29

    I recently gave 13wincom a try. The interface is clean, and I liked the variety of games they offered. Give them a try! 13wincom

  9. 3 weeks ago
    2026-10-15 6:58:17

    I’ve tried a few platforms but this one really stands out. The payout is fast and the games are super smooth. Definitely my new go-to spot! phsuperace777

  10. 2 weeks ago
    2026-10-18 21:08:09

    I really appreciate the welcome bonus they gave me. It gave me enough credit to explore all the different rooms. vnzs88 is definitely a top tier choice.

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next