zoukankan      html  css  js  c++  java
  • H-数学考试 想法题+最新头文件 2018年长沙理工大学第十三届程序设计竞赛

     https://www.nowcoder.com/acm/contest/96/H

    坑点:INF开太小了。。。

    #define _CRT_SECURE_NO_WARNINGS
    #include<cstring>
    #include<cctype>
    #include<cmath>
    #include<cstdio>
    #include<string>
    #include<stack>
    #include<ctime>
    #include<list>
    #include<set>
    #include<map>
    #include<queue>
    #include<vector>
    #include<sstream>
    #include<iostream>
    #include<algorithm>
    //#define INF 0x3f3f3f3f
    #define eps 1e-6
    #define pi acos(-1.0)
    #define e exp(1.0)
    #define fre(i,t,n)  for(int i =(t);i<=(n);++i)
    #define fer(i,n,t)  for(int i =(n);i>=(t);--i)
    #define mp make_pair
    #define pb push_back
    //std::ios::sync_with_stdio(false);
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    void smain();
    #define ONLINE_JUDGE
    int main() {
        ios::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        long _begin_time = clock();
    #endif
        smain();
    #ifndef ONLINE_JUDGE
        long _end_time = clock();
        printf("time = %ld ms.", _end_time - _begin_time);
    #endif
    return 0;
    }
    const int maxn = 2e5 + +100;
    const int mod = 1e9 + 7;
    const ll INF= (100000)*(200000ll) + 1000;
    ll a[maxn], b[maxn], mx[maxn];
    
    void Run() {
        fre(i, 0, maxn) mx[i] = -INF;
        int n, k;
        cin >> n >> k;
        fre(i, 1, n)cin >> a[i];
        fre(i, 1, n) a[i] += a[i - 1];
        fre(i, k, n)b[i] = a[i] - a[i - k]; 
        fre(i, k, n)mx[i] = max(mx[i - 1], b[i]);
        ll ans = -INF;
        fre(i, 2 * k, n) {
            ans = max(ans, mx[i - k] + b[i]);
        }
        cout << ans ;
    }
    void smain() {
        int t;
        cin >> t;
        while (t--) {
            Run();
            cout << endl;
        }
    }
    成功的路并不拥挤,因为大部分人都在颓(笑)
  • 相关阅读:
    htmilunit-- 针对抓取js生成的数据
    httpClient get方式抓取数据
    post方式的数据抓取
    利用win10自带的系统配置禁止开机启动项和程序
    linq中怎么实现多条件关联的左右连接
    win10提示管理员已阻止你运行此应用,如何强制运行
    远程连接SQL Server 2014遇到的问题和解决
    eclipse中删除多余的tomcat server
    resultMap之collection聚集
    empty()和remove()的区别
  • 原文地址:https://www.cnblogs.com/SuuT/p/8870100.html
Copyright © 2011-2022 走看看