AtCoder Regular Contest 017

Submission #1015465

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() {
  int n, k;
  scanf("%d %d", &n, &k);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  if (n < k) {
    printf("0\n");
    return 0;
  }
  int l = 0;
  int r = 1;
  int maxi = 1;
  int ans = 0;
  for (; r < n;) {
    if (a[r-1] >= a[r]) {
      l = r;
      r += 1;
      ans += max(0, maxi + 1 - k);
      maxi = 1;
      continue;
    }
    r += 1;
    maxi = max(maxi, r - l);
  }
  ans += max(0, maxi + 1 - k);
  printf("%d\n", ans);

  return 0;
}

Submission

Task問題 B - 解像度が低い。
User nameユーザ名 mu
Created time投稿日時
Language言語 C++11 (GCC 4.8.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1469 Byte
File nameファイル名
Exec time実行時間 52 ms
Memory usageメモリ使用量 2080 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &k);
^
./Main.cpp:46:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 decr2_1.txt,decr2_2.txt,decr_1.txt,decr_2.txt,incr2_1.txt,incr2_2.txt,incr2_3.txt,incr_1.txt,incr_2.txt,incr_3.txt,incr_4.txt,incr_5.txt,ins_1.txt,ins_2.txt,ins_3.txt,ins_4.txt,ins_5.txt,ins_6.txt,ins_7.txt,ins_8.txt,ins_9.txt,random_1.txt,random_2.txt,random_3.txt,random_4.txt,random_5.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
decr2_1.txt AC 22 ms 928 KB
decr2_2.txt AC 21 ms 924 KB
decr_1.txt AC 20 ms 928 KB
decr_2.txt AC 21 ms 924 KB
incr2_1.txt AC 30 ms 1176 KB
incr2_2.txt AC 29 ms 1180 KB
incr2_3.txt AC 29 ms 1224 KB
incr_1.txt AC 50 ms 2076 KB
incr_2.txt AC 28 ms 1304 KB
incr_3.txt AC 51 ms 1952 KB
incr_4.txt AC 50 ms 1952 KB
incr_5.txt AC 50 ms 2080 KB
ins_1.txt AC 50 ms 2076 KB
ins_2.txt AC 50 ms 1948 KB
ins_3.txt AC 49 ms 2080 KB
ins_4.txt AC 52 ms 2076 KB
ins_5.txt AC 50 ms 2076 KB
ins_6.txt AC 50 ms 1948 KB
ins_7.txt AC 50 ms 2072 KB
ins_8.txt AC 50 ms 2072 KB
ins_9.txt AC 51 ms 1944 KB
random_1.txt AC 52 ms 2076 KB
random_2.txt AC 43 ms 2076 KB
random_3.txt AC 52 ms 2076 KB
random_4.txt AC 52 ms 1952 KB
random_5.txt AC 50 ms 1948 KB
sample_1.txt AC 17 ms 800 KB
sample_2.txt AC 17 ms 844 KB
sample_3.txt AC 16 ms 800 KB
sample_4.txt AC 18 ms 796 KB