QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#429867#8777. Passport Stampsskittles1412#WA 7ms4580kbC++176.6kb2024-06-02 23:45:422024-06-02 23:45:42

Judging History

你现在查看的是最新测评结果

  • [2024-06-02 23:45:42]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:4580kb
  • [2024-06-02 23:45:42]
  • 提交

answer

// cf bits/extc++.h nonsense
#ifdef ONLINE_JUDGE
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#endif

#line 1 "j.cpp"
// 69683a8183e36171b0123a3fbef815656276c8d9
#include "bits/extc++.h"
#line 1 "/home/skittles1412/workspace/cp/library/template.hpp"



#line 5 "/home/skittles1412/workspace/cp/library/template.hpp"

using namespace std;

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t;
    ((cerr << " | " << u), ...);
    cerr << endl;
}

#ifdef DEBUG
#define dbg(...)                                           \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
         << ": ";                                          \
    dbgh(__VA_ARGS__)
#else
#define cerr   \
    if (false) \
    cerr
#define dbg(...)
#endif

using u32 = uint32_t;
using u64 = uint64_t;
using ld = long double;

#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))


#line 1 "/home/skittles1412/workspace/cp/library/utils.hpp"



#line 5 "/home/skittles1412/workspace/cp/library/utils.hpp"

template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
    out << "[";
    for (int i = 0; i < sz(arr); i++) {
        if (i) {
            out << ", ";
        }
        out << arr[i];
    }
    return out << "]";
}

template <typename T, size_t N>
ostream& operator<<(ostream& out, const array<T, N>& arr) {
    out << "[";
    for (size_t i = 0; i < N; i++) {
        if (i) {
            out << ", ";
        }
        out << arr[i];
    }
    return out << "]";
}

template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}

/**
 * Computes the first x in [l, r) such that cb(x) is true.
 *
 * If no x in that range is true, returns r
 */
template <typename T, typename Cb>
T first_true(T l, T r, const Cb& cb) {
    while (l < r) {
        T mid = (l + r) / 2;
        if (cb(mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    return l;
}

/**
 * Computes the last x in (l, r] such that cb(x) is true.
 *
 * If no x in that range is true, returns l
 */
template <typename T, typename Cb>
T last_true(T l, T r, const Cb& cb) {
    while (l < r) {
        T mid = (l + r + 1) / 2;
        if (cb(mid)) {
            l = mid;
        } else {
            r = mid - 1;
        }
    }
    return l;
}

template <typename T>
T reversed(T arr) {
    reverse(begin(arr), end(arr));
    return arr;
}

template <typename T>
bool is_palin(const T& arr) {
    return arr == reversed(arr);
}

template <typename T>
T sorted(T arr) {
    sort(begin(arr), end(arr));
    return arr;
}

template <typename T>
T negated(T arr) {
    for (auto& a : arr) {
        a = -a;
    }
    return arr;
}

template <typename T, bool STRICT>
vector<int> comp_prev_helper(const vector<T>& arr) {
    int n = sz(arr);

    vector<int> ans(n);

    vector<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        auto cmp = [&]() -> bool {
            if constexpr (STRICT) {
                return st.back().first <= arr[i];
            } else {
                return st.back().first < arr[i];
            }
        };
        while (sz(st) && cmp()) {
            st.pop_back();
        }

        if (sz(st)) {
            ans[i] = st.back().second;
        } else {
            ans[i] = -1;
        }
        st.emplace_back(arr[i], i);
    }

    return ans;
}

/**
 * Computes ans[i], the closest index j to the left of i where arr[j] > arr[i]
 *
 * ans[i] = -1 if no such j exists
 */
template <typename T>
vector<int> comp_prev_gt(const vector<T>& arr) {
    return comp_prev_helper<T, true>(arr);
}

/**
 * Computes ans[i], the closest index j to the left of i where arr[j] >= arr[i]
 *
 * ans[i] = -1 if no such j exists
 */
template <typename T>
vector<int> comp_prev_ge(const vector<T>& arr) {
    return comp_prev_helper<T, false>(arr);
}

/**
 * reverses an array of indices
 *
 * specifically, it reverses the array and computes arr[i] = n - 1 - arr[i]
 */
vector<int> reverse_indices(vector<int> arr) {
    int n = sz(arr);

    reverse(begin(arr), end(arr));
    for (auto& a : arr) {
        a = n - 1 - a;
    }

    return arr;
}

/**
 * Computes ans[i], the closest index j to the right of i where arr[j] > arr[i]
 *
 * ans[i] = n if no such j exists
 */
template <typename T>
vector<int> comp_next_gt(vector<T> arr) {
    reverse(begin(arr), end(arr));

    return reverse_indices(comp_prev_gt(arr));
}

/**
 * Computes ans[i], the closest index j to the right of i where arr[j] >= arr[i]
 *
 * ans[i] = n if no such j exists
 */
template <typename T>
vector<int> comp_next_ge(vector<T> arr) {
    reverse(begin(arr), end(arr));

    return reverse_indices(comp_prev_ge(arr));
}

template <typename Cb>
struct CmpByKey {
    Cb cb;

    explicit CmpByKey(const Cb& cb) : cb(cb) {}

    template <typename T>
    bool operator()(const T& a, const T& b) const {
        return cb(a) < cb(b);
    }
};

/**
 * outputs will be in the range [0, m), returns m
 */
int coord_comp(const vector<int*>& arr) {
    vector<int> vals;
    for (auto& a : arr) {
        vals.push_back(*a);
    }

    sort(begin(vals), end(vals));
    vals.erase(unique(begin(vals), end(vals)), end(vals));

    for (auto& a : arr) {
        *a = int(lower_bound(begin(vals), end(vals), *a) - begin(vals));
    }

    return sz(vals);
}

/**
 * outputs will be in the range [0, m), returns {m, result}
 */
template <typename T>
pair<int, vector<int>> coord_comp(const vector<T>& arr) {
    vector<T> vals = arr;
    sort(begin(vals), end(vals));
    vals.erase(unique(begin(vals), end(vals)), end(vals));

    vector<int> ans;
    for (auto& a : arr) {
        ans.push_back(
            int(lower_bound(begin(vals), end(vals), a) - begin(vals)));
    }

    return {sz(vals), ans};
}

template <typename T>
bool on(T mask, int bit) {
    return (mask >> bit) & 1;
}


#line 5 "j.cpp"

using i128 = __int128_t;

void solve() {
    int n;
    long m;
    cin >> n >> m;

    long arr[n];
    for (auto& a : arr) {
        cin >> a;
    }

    long psum = 0;
    for (int i = 0; i < n; i++) {
        if (i128(i) * (arr[i] - 1) + psum + 1 > m) {
            cout << i << endl;
            return;
        }

        psum += arr[i];
    }
    cout << n << endl;
}

int main() {
    cin.tie(nullptr);
    cin.exceptions(ios::failbit);
    ios_base::sync_with_stdio(false);
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3744kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 3ms
memory: 4356kb

input:

100000 559309580160692839
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

84437

result:

ok single line: '84437'

Test #3:

score: 0
Accepted
time: 3ms
memory: 4364kb

input:

100000 890934113082207108
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

53636

result:

ok single line: '53636'

Test #4:

score: 0
Accepted
time: 3ms
memory: 4376kb

input:

100000 132839930703581978
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

59360

result:

ok single line: '59360'

Test #5:

score: 0
Accepted
time: 3ms
memory: 4568kb

input:

100000 761263352659137865
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

67748

result:

ok single line: '67748'

Test #6:

score: 0
Accepted
time: 3ms
memory: 4348kb

input:

100000 654001515423941861
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

25745

result:

ok single line: '25745'

Test #7:

score: 0
Accepted
time: 3ms
memory: 4508kb

input:

100000 755568812034403272
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

40873

result:

ok single line: '40873'

Test #8:

score: 0
Accepted
time: 3ms
memory: 4580kb

input:

100000 783129347604694200
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

44527

result:

ok single line: '44527'

Test #9:

score: 0
Accepted
time: 0ms
memory: 4352kb

input:

100000 905120603799436149
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

58851

result:

ok single line: '58851'

Test #10:

score: 0
Accepted
time: 3ms
memory: 4292kb

input:

100000 240004036785370527
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

42660

result:

ok single line: '42660'

Test #11:

score: 0
Accepted
time: 3ms
memory: 4388kb

input:

100000 548919634536408821
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

30657

result:

ok single line: '30657'

Test #12:

score: 0
Accepted
time: 6ms
memory: 4252kb

input:

100000 75636237219086009
1
37818118609543001
12606039536514334
6303019768257167
3781811860954300
2521207907302866
1800862790930619
1350647093197964
1050503294709528
840402635767622
687602156537145
573001797114288
484847674481320
415583720983989
360172558186124
315150988412858
278074401540757
2471772...

output:

100000

result:

ok single line: '100000'

Test #13:

score: 0
Accepted
time: 6ms
memory: 4540kb

input:

100000 236447379349717830
1
118223689674858912
39407896558286304
19703948279143152
11822368967485891
7881579311657261
5629699508326615
4222274631244961
3283991379857192
2627193103885753
2149521630451980
1791268025376650
1515688329164858
1299161424998449
1125939901665323
985197413957157
8692918358445...

output:

100000

result:

ok single line: '100000'

Test #14:

score: 0
Accepted
time: 6ms
memory: 4296kb

input:

100000 238284828602599618
1
119142414301299807
39714138100433269
19857069050216634
11914241430129980
7942827620086654
5673448300061895
4255086225046421
3309511508369439
2647609206695551
2166225714569087
1805188095474239
1527466850016664
1309257300014283
1134689660012379
992853452510832
8760471639801...

output:

100000

result:

ok single line: '100000'

Test #15:

score: 0
Accepted
time: 6ms
memory: 4504kb

input:

100000 209481399482344513
1
104740699741172255
34913566580390751
17456783290195376
10474069974117225
6982713316078150
4987652368627250
3740739276470437
2909463881699229
2327571105359383
1904376358930404
1586980299108670
1342829483861183
1150996700452442
997530473725450
872839164509769
77015220397920...

output:

100000

result:

ok single line: '100000'

Test #16:

score: 0
Accepted
time: 6ms
memory: 4360kb

input:

100000 160284526594608875
1
80142263297304436
26714087765768145
13357043882884073
8014226329730443
5342817553153629
3816298252252592
2862223689189444
2226173980480679
1780939184384543
1457132059950989
1214276716625825
1027464914068005
880684212058290
763259650450518
667852194144203
589281347774297
5...

output:

100000

result:

ok single line: '100000'

Test #17:

score: 0
Accepted
time: 7ms
memory: 4504kb

input:

100000 852095496567419553
1
426047748283709776
142015916094569925
71007958047284962
42604774828370977
28403183218913985
20287988013509989
15215991010132492
11834659674547494
9467727739637995
7746322696067450
6455268913389542
5462150619021920
4681843387733074
4057597602701998
3550397902364248
3132704...

output:

100000

result:

ok single line: '100000'

Test #18:

score: 0
Accepted
time: 6ms
memory: 4308kb

input:

100000 787884515487196686
1
393942257743598343
131314085914532781
65657042957266390
39394225774359834
26262817182906556
18759155130647540
14069366347985655
10942840492877731
8754272394302185
7162586504429061
5968822087024217
5050541765943568
4329035799380201
3751831026129508
3282852147863319
2896634...

output:

100000

result:

ok single line: '100000'

Test #19:

score: -100
Wrong Answer
time: 7ms
memory: 4372kb

input:

100000 705443926439369243
1
352721963219684622
117573987739894874
58786993869947437
35272196321968462
23514797547978974
16796283962842125
12597212972131593
9797832311657906
7838265849326325
6413126603994266
5344272169995221
4522076451534418
3876065529886644
3359256792568425
2939349693497372
25935438...

output:

100000

result:

wrong answer 1st lines differ - expected: '1', found: '100000'