合集-Google Competition

摘要:Longest Arithmetic 题意 给一个长为n的数组,求其中最长的等差子串长度。 思路 从2开始遍历,维护上一个差,然后判断当前i和i-1的差是否相等。同时记录答案 代码 #include<bits/stdc++.h> using namespace std; const int MAX= 阅读全文
posted @ 2022-11-23 16:41 cryingrain 阅读(53) 评论(0) 推荐(0)
摘要:Record Breaker 题意 给一个长为n的数组a,从左往右计算,如果某个a[i]比之前出现过的所有a[j]都更大,并且比a[i+1]更大,那么认为a[i]打破纪录,求有多少打破纪录的a[i]。 思路 遍历 代码 #include<bits/stdc++.h> using namespace 阅读全文
posted @ 2022-10-20 00:50 cryingrain 阅读(75) 评论(0) 推荐(0)
摘要:Countdown 题意 给一个长为n的数组,一个数k,求数组中有多少个子串组成k,k-1,k-2....2,1 思路 扫一遍记录当前期望的值就行了。 代码 #include<bits/stdc++.h> using namespace std; int main() { int T,cas=0; 阅读全文
posted @ 2022-10-13 23:02 cryingrain 阅读(61) 评论(0) 推荐(0)