AtCoder Beginner Contest 032

Submission #1014686

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll n, k;
  scanf("%lld %lld", &n, &k);
  vll x(n);
  rep (i, n) {
    scanf("%lld", &x[i]);
  }
  int start = -1;
  rep (i, n) {
    if (x[i] == 0) {
      printf("%lld\n", n);
      return 0;
    }
  }
  rep (i, n) {
    if (x[i] <= k) {
      start = i;
      break;
    }
  }
  if (start == -1) {
    printf("0\n");
    return 0;
  }
  ll product = x[start];
  int l = start;
  int r = start + 1;
  int ans = 1;
  for (;;) {
    if (r == n) {
      break;
    }
    product *= x[r];
    r += 1;
    if (product <= k) {
      ans = max(ans, r - l);
      continue;
    }
    while (product > k) {
      product /= x[l];
      l += 1;
    }
  }
  printf("%d\n", ans);

  return 0;
}

Submission

Task問題 C - 列
User nameユーザ名 cyglef
Created time投稿日時
Language言語 C++14 (Clang++ 3.4)
Status状態 AC
Score得点 100
Source lengthソースコード長 1711 Byte
File nameファイル名
Exec time実行時間 33 ms
Memory usageメモリ使用量 1696 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt,subtask0_sample_04.txt
Subtask1 20 / 20 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 80 / 80 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_sample_01.txt AC 17 ms 800 KB
subtask0_sample_02.txt AC 16 ms 796 KB
subtask0_sample_03.txt AC 18 ms 796 KB
subtask0_sample_04.txt AC 18 ms 920 KB
subtask1_01.txt AC 18 ms 800 KB
subtask1_02.txt AC 19 ms 924 KB
subtask1_03.txt AC 18 ms 800 KB
subtask1_04.txt AC 18 ms 924 KB
subtask1_05.txt AC 17 ms 844 KB
subtask1_06.txt AC 18 ms 800 KB
subtask1_07.txt AC 18 ms 924 KB
subtask1_08.txt AC 18 ms 928 KB
subtask1_09.txt AC 18 ms 924 KB
subtask1_10.txt AC 18 ms 928 KB
subtask1_11.txt AC 18 ms 924 KB
subtask1_12.txt AC 18 ms 796 KB
subtask1_13.txt AC 18 ms 920 KB
subtask1_14.txt AC 18 ms 924 KB
subtask1_15.txt AC 16 ms 924 KB
subtask1_16.txt AC 16 ms 884 KB
subtask1_17.txt AC 16 ms 924 KB
subtask1_corner.txt AC 18 ms 796 KB
subtask1_killer1.txt AC 18 ms 928 KB
subtask1_killer2.txt AC 18 ms 920 KB
subtask1_killer3.txt AC 18 ms 844 KB
subtask1_killer4.txt AC 16 ms 800 KB
subtask1_killer5.txt AC 18 ms 920 KB
subtask2_01.txt AC 24 ms 1564 KB
subtask2_02.txt AC 27 ms 1688 KB
subtask2_03.txt AC 33 ms 1568 KB
subtask2_04.txt AC 28 ms 1692 KB
subtask2_05.txt AC 31 ms 1556 KB
subtask2_06.txt AC 31 ms 1552 KB
subtask2_07.txt AC 28 ms 1564 KB
subtask2_08.txt AC 29 ms 1692 KB
subtask2_09.txt AC 28 ms 1696 KB
subtask2_10.txt AC 27 ms 1692 KB
subtask2_11.txt AC 29 ms 1684 KB
subtask2_12.txt AC 29 ms 1568 KB
subtask2_13.txt AC 29 ms 1560 KB
subtask2_14.txt AC 29 ms 1692 KB
subtask2_15.txt AC 33 ms 1552 KB
subtask2_16.txt AC 27 ms 1696 KB
subtask2_17.txt AC 27 ms 1696 KB