蓝桥杯-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;
}
相关推荐
无定义_1 小时前
10.11日常训练
算法
Code_Solitude1 小时前
c语言:关于qsoet函数知识点
c语言·数据结构·算法
Nil2081 小时前
leetcode 49字母异位分组
算法·leetcode·哈希算法
weixin_307779132 小时前
C++代码实现MATLAB中的spectralcluster函数功能
开发语言·c++·算法·matlab
行者全栈架构师2 小时前
【鸿蒙心迹】让应用“悬浮“起来——闪控球(floatingBall)从接入到实战全链路(HarmonyOS 7.x)
前端·算法·架构
云的雨 雨的云2 小时前
手写算法动画上位机:从排序到线性代数可视化
线性代数·算法
Pniubi2 小时前
快速排序(力扣基础)(递归)
java·数据结构·算法
roman_日积跬步-终至千里2 小时前
【数据Agent论文·分析与报告评测|27】ComInsight:原子洞察正确,组合后的结论就可靠吗?
人工智能·算法·机器学习·数据分析
Samson Bruce3 小时前
【数学之美】
线性代数·算法·概率论
Mister Leon3 小时前
Nvidia Orin AGX实战之从量化到蒸馏:在 Orin 上落地的大模型压缩实战
人工智能·算法·机器学习