Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Created March 20, 2014 09:14
Show Gist options
  • Save KT-Yeh/9660013 to your computer and use it in GitHub Desktop.
Save KT-Yeh/9660013 to your computer and use it in GitHub Desktop.
#include <cstdio>
using namespace std;
int num[20001];
int main()
{
int Case, S;
scanf("%d", &Case);
for (int i = 1; i <= Case; ++i)
{
int num, MSS = -1, Start = -1, End = -1;
int Max = 0, Max_Start, Max_End;
scanf("%d", &S);
for (int j = 1; j <= S - 1; ++j){
scanf("%d", &num);
if (MSS >= 0)
MSS += num;
else {
MSS = num;
Start = j;
}
if (MSS > Max ||
(MSS == Max && j+1 - Start > Max_End - Max_Start))
{
Max = MSS;
Max_Start = Start;
Max_End = j + 1;
}
}
if (Max == 0)
printf("Route %d has no nice parts\n", i);
else
printf("The nicest part of route %d is between stops %d and %d\n", i, Max_Start, Max_End);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment