Submission #11171624


Source Code Expand

Copy
#include <bits/stdc++.h>
#include <cmath>

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

void tow_pointer(int n,
                 function<bool(int left)> check_begin,
                 function<void(int left)> begin,
                 function<bool(int right)> check_right,
                 function<void(int right)> push_right,
                 function<void(int left)> pop_left,
                 function<void(int left, int right)> dead_end
) {

    auto go = [&](P range) {
        int right = -1;
        for (int left = range.first; left <= range.second; left++) {
            if (right < left) {
                right = left;
                begin(left);
            }
            while (right + 1 <= range.second && check_right(right + 1)) {
                right++;
                push_right(right);
            }
            dead_end(left, right);
            pop_left(left);
        }
    };


    auto get_ranges = [&] {
        vector<bool> enable_items(n);
        rep(i, n) enable_items[i] = check_begin(i);

        auto start = [&](int i) {
            if (i == 0) {
                return enable_items[i] == true;
            }
            if (!enable_items[i - 1] && enable_items[i]) {
                return true;
            }
            return false;
        };

        auto end = [&](int i) {

            if (i == n - 1) {
                return enable_items[i] == true;
            }

            if (enable_items[i] && !enable_items[i + 1]) {
                return true;
            }

            return false;
        };

        vector<P> ans;
        P p;
        rep(i, n) {
            if (start(i)) {
                p = P(i, -1);
            }
            if (end(i)) {
                p.second = i;
                ans.push_back(p);
            }
        }
        return ans;
    };


    vector<P> ranges = get_ranges();
    for (P range: ranges) go(range);
}


int main() {
    int n;
    ll k;
    cin >> n >> k;

    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    if (find(numbers.begin(), numbers.end(), 0ll) != numbers.end()) {
        cout << n << endl;
        ret();
    }
    ll sum = 0;
    auto check_begin = [&](int i) {
        return numbers[i] <= k;
    };

    auto begin = [&](int i) {
        sum = numbers[i];
    };

    auto check_right = [&](int right) {
        return sum * numbers[right] <= k;
    };

    auto push_right = [&](int right) {
        sum *= numbers[right];
    };

    auto pop_left = [&](int left) {
        assert(sum % numbers[left] == 0);
        sum /= numbers[left];
    };

    ll ans = 0;

    auto dead_end = [&](int left, int right) {
        ll now = right - left + 1;
        cmax(ans, now);
    };


    tow_pointer(
            n,
            check_begin,
            begin,
            check_right,
            push_right,
            pop_left,
            dead_end
    );
    cout << ans << endl;

}

Submission Info

Submission Time
Task C - 列
User riku_tanide
Language C++14 (GCC 5.4.1)
Score 100
Code Size 4110 Byte
Status AC
Exec Time 46 ms
Memory 1152 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 20 / 20 80 / 80
Status
AC × 4
AC × 27
AC × 44
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt
Subtask1 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_corner.txt, subtask1_killer1.txt, subtask1_killer2.txt, subtask1_killer3.txt, subtask1_killer4.txt, subtask1_killer5.txt
Subtask2 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_corner.txt, subtask1_killer1.txt, subtask1_killer2.txt, subtask1_killer3.txt, subtask1_killer4.txt, subtask1_killer5.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask0_sample_03.txt AC 1 ms 256 KB
subtask0_sample_04.txt AC 1 ms 256 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 2 ms 256 KB
subtask1_03.txt AC 2 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 2 ms 256 KB
subtask1_06.txt AC 2 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 1 ms 256 KB
subtask1_11.txt AC 1 ms 256 KB
subtask1_12.txt AC 1 ms 256 KB
subtask1_13.txt AC 1 ms 256 KB
subtask1_14.txt AC 1 ms 256 KB
subtask1_15.txt AC 2 ms 256 KB
subtask1_16.txt AC 1 ms 256 KB
subtask1_17.txt AC 1 ms 256 KB
subtask1_corner.txt AC 1 ms 256 KB
subtask1_killer1.txt AC 1 ms 256 KB
subtask1_killer2.txt AC 1 ms 256 KB
subtask1_killer3.txt AC 1 ms 256 KB
subtask1_killer4.txt AC 1 ms 256 KB
subtask1_killer5.txt AC 1 ms 256 KB
subtask2_01.txt AC 18 ms 1152 KB
subtask2_02.txt AC 19 ms 1024 KB
subtask2_03.txt AC 43 ms 1024 KB
subtask2_04.txt AC 20 ms 1024 KB
subtask2_05.txt AC 41 ms 1024 KB
subtask2_06.txt AC 41 ms 1024 KB
subtask2_07.txt AC 20 ms 1024 KB
subtask2_08.txt AC 20 ms 1024 KB
subtask2_09.txt AC 20 ms 1024 KB
subtask2_10.txt AC 20 ms 1024 KB
subtask2_11.txt AC 20 ms 1024 KB
subtask2_12.txt AC 25 ms 1024 KB
subtask2_13.txt AC 25 ms 1024 KB
subtask2_14.txt AC 26 ms 1024 KB
subtask2_15.txt AC 46 ms 1024 KB
subtask2_16.txt AC 20 ms 1024 KB
subtask2_17.txt AC 20 ms 1024 KB