/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 9ms 532.0 KiB
#3 Accepted 15ms 532.0 KiB
#4 Accepted 15ms 324.0 KiB
#5 Accepted 15ms 532.0 KiB
#6 Accepted 16ms 1.309 MiB
#7 Accepted 15ms 2.023 MiB
#8 Accepted 14ms 2.082 MiB
#9 Wrong Answer 5ms 532.0 KiB

Code

#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define sp << " " << 
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define PI 3.1415926535897932384626

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sortall(x) sort(all(x))
#define sortrall(x) sort(rall(x))

#define printv(v) for(auto x : v) cout << x << " "; cout << "\n"
#define printm(m) for(auto x : m) cout << x.F sp x.S << "\n"

#define make_unique(x) sortall(x); (x).resize(unique(all(x)) - (x).begin())

const int mod = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<typename T1, typename T2>
using safe_map = unordered_map<T1, T2, custom_hash>;

template<typename T>
using safe_set = unordered_set<T, custom_hash>;

template<typename T>
void debug(T x) {
    cerr << x << endl;
}

template<typename T, typename... Args>
void debug(T x, Args... args) {
    cerr << x << " ";
    debug(args...);
}

void fastIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void fraction() {
    cout.unsetf(ios::floatfield); 
    cout.precision(10); 
    cout.setf(ios::fixed,ios::floatfield);
}

void yn(bool res, bool cap = false) {
    if(!cap) cout << ((res) ? "YES\n" : "NO\n");
    else cout << ((res) ? "Yes\n" : "No\n");
}

inline int nxt() {
    int x;
    cin >> x;
    return x;
}
 
void proc(){

}

void solve() {
    int n, k, d; cin >> n >> k >> d;
    vector<ll> v(n);
    for(auto &x : v) cin >> x;
    ll r = 0;
    int ans = INF;
    for(int i = 0; i < k; i++) r += v[i];
    if(r % d == 0) {
        cout << "1\n";
        return;
    }
    bool mx = false;
    for(int i = k; i < n; i++) {
        r += v[i];
        r -= v[i-k];
        if(r % d == 0) {
            ans = min(ans, i-k+2);
            if(r == d) {
                ans = i-k+2;
                break;
            }
        }
    }
    if(ans == INF) cout << "-1\n";
    else cout << ans << "\n";
}

int main() {
    fastIO(); 
    proc();

    int tc = 1;
    tc = nxt();
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1190 Segment Strength
Contest
Brain Booster #9
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 15:48:50
Judged At
2025-04-06 15:48:50
Judged By
Score
75
Total Time
16ms
Peak Memory
2.082 MiB