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 ;
}
const int maxn = 2e5 + +;
const int mod = 1e9 + ;
const ll INF= ()*(200000ll) + ;
ll a[maxn], b[maxn], mx[maxn]; void Run() {
fre(i, , maxn) mx[i] = -INF;
int n, k;
cin >> n >> k;
fre(i, , n)cin >> a[i];
fre(i, , n) a[i] += a[i - ];
fre(i, k, n)b[i] = a[i] - a[i - k];
fre(i, k, n)mx[i] = max(mx[i - ], b[i]);
ll ans = -INF;
fre(i, * k, n) {
ans = max(ans, mx[i - k] + b[i]);
}
cout << ans ;
}
void smain() {
int t;
cin >> t;
while (t--) {
Run();
cout << endl;
}
}
上一篇:mysql主从复制的配置总结


下一篇:DoNet屌丝学Android(一)——Android开发准备工作 & No HelloWord & (真机)调试