[Blog] [Docs] [Code] [Slides] [About]

KickStart 2020 Round D-A Record Breaker

水题

2020-07-15 20:32 CST

题目 题解和总结:/blog/2020-07-15-ks-2020-d/

Code

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int T = 0;
  scanf("%d", &T);
  for (int t = 1; t <= T; ++t) {
    int n = 0;
    vector<int> v;
    scanf("%d", &n);
    v.resize(n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &v[i]);
    }
    int ans = n == 1 || v[0] > v[1], vmax = v[0];
    for (int i = 1; i < n; ++i) {
      if (v[i] > vmax && (i == n - 1 || v[i] > v[i + 1])) {
        ++ans;
      }
      vmax = max(vmax, v[i]);
    }
    printf("Case #%d: %d\n", t, ans);
  }
}
<EOF>