zoukankan      html  css  js  c++  java
  • 数学考试

    https://ac.nowcoder.com/acm/problem/15553

    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    const int maxn=2e5+5;
    int t,n,k,s[maxn],maxpre;
    int ans;
    signed main(){
        //freopen("in","r",stdin);
        ios::sync_with_stdio(0);
        cin >> t;
        while(t--){
            cin >> n >> k;
            for(int i = 1; i <= n; i++){
                cin >> s[i];
                s[i] += s[i - 1];
            }
            maxpre = ans = -1e10;
            for(int i = k; i + k <= n; i++){
                maxpre = max(maxpre,s[i] - s[i - k]);
                ans = max(ans,maxpre + s[i + k] - s[i]);
            }
            cout << ans << endl;
        }
        return 0;
    }
  • 相关阅读:
    网络编程
    模块
    内置函数
    函数应用
    万能参数
    函数
    爬虫
    算法
    Flask
    linux
  • 原文地址:https://www.cnblogs.com/xcfxcf/p/12930969.html
Copyright © 2011-2022 走看看