蓝桥杯-15届研究生组-A 劲舞团

思路和时间复杂度

  1. 思路:签到模拟题,但是思路也很重要,在K的重新赋值时,卡了一下,在不满足时间条件时,应该重置为1
  2. 时间复杂度:

代码

cpp 复制代码
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
  // 请在此输入您的代码
  char x, y;
  long long t;
  int maxK = 0;
  int K = 0;
  long long preT = -1;
  while(cin>>x>>y>>t){
    if(x != y){
      K = 0;
      preT = t;
      continue;
    }
    if(preT == -1){
      K = 1;
    }else{
      if(t - preT <= 1000){
        K++;
      }else{
        K = 1;
      }
    }
    maxK = max(maxK, K);
    preT = t;
    
  }

  cout<<maxK;


  return 0;
}
相关推荐
晴天的雨.9928 分钟前
[C++算法]快乐数
数据结构·c++·算法
孤狼warrior12 分钟前
SCTR 五次失败的安全 BN 路由器
人工智能·python·深度学习·算法·安全·yolo
影视飓风TIM14 分钟前
C++11 核心新特性完整梳理
数据结构·c++·算法
晴天的雨.99216 分钟前
[C++]算法双指针 复写0
数据结构·c++·算法
橘子汽水16830 分钟前
Leetcode 128,49最长连续序列,字母异位词分组
java·算法·leetcode
mmmmath_332 分钟前
LeetCode.438.找到字符串中所有字母异位词
数据结构·算法·leetcode
Nil20837 分钟前
leetcode 22括号生成
算法·leetcode·深度优先
Navigator_Z41 分钟前
LeetCode //C - 1237. Find Positive Integer Solution for a Given Equation
c语言·算法·leetcode