比赛 20150421 评测结果 AATTTTTT
题目名称 山海经 最终得分 25
用户昵称 wolf. 运行时间 6.001 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2015-04-21 09:33:44
显示代码纯文本
#include<iostream>
#include<fstream>
#include<bitset>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdio>
using namespace std;
#if defined wolf
const string ok="OK";
const string kk="	";
ofstream nnew("hill.in",ios::app);
ifstream fin("hill.in");
#define fout cout
#define Endl endl
#else
ifstream fin("hill.in");
ofstream fout("hill.out");
#endif
vector<long long> TT;
void core(int a,int b){
	int m,n;
	m=0;n=0;
	long long mmax=-999999999;
	for(int i=a;i<=b;++i){
		for(int j=i;j<=b;++j){
			if(TT[j]-TT[i-1]>mmax){
				mmax=TT[j]-TT[i-1];
				m=i;n=j;
			}
		}
	}
	fout<<m<<"  "<<n<<"  "<<mmax<<endl;
}
int main(){
	int n,m;
	fin>>n>>m;
	TT.push_back(0);
	for(int i=0;i!=n;++i){
		int e;
		fin>>e;
		TT.push_back(e+TT[i]);
	}
	for(int i=0;i!=m;++i){
		int a,b;
		fin>>a>>b;
		core(a,b);
	}
	//-------------------------*/
	#if defined wolf
	cout<<endl<<(double)clock()/CLOCKS_PER_SEC<<'s'<<endl;
	#endif
	return 0;
}
//Designed by wolf
//Tue Apr 21 2015