#include<iostream> #include<cstdio> #include<vector> #include<utility> #include<ctime> #include<algorithm> #define db(a) cout << #a << " = " << a << endl #define db2(a, b) cout << #a << " = " << a << " " << #b << " = " << b << endl #define db3(a, b, c) cout << #a << " = " << a << " " << #b << " = " << b << " " << #c << " = " << c << endl using namespace std; int main() { #ifdef dennisbot freopen("in.in", "r", stdin); //freopen("ou.out", "w", stdout); clock_t start = clock(); #endif int b, s; cin >> b; for (int i = 0; i < b; i++) { cin >> s; int sum = -1, cur = 0, inf = 0, sup = 0, max = -1, var, d = 0; for (int j = 0; j < s - 1; j++) { cin >> var; if (j != 0) { if (sum >= 0) sum += var; else sum = var, cur = j; if (sum == max and j - cur > d or sum > max) inf = cur, sup = j, max = sum, d = sup - inf; } else sum = var, max = var; } if (max > 0) printf("The nicest part of route %d is between stops %d and %d\n", i + 1, inf + 1, sup + 2); else printf("Route %d has no nice parts\n", i + 1); } #ifdef dennisbot printf("\ntime=%.3fs\n", (clock() - start) * 1. / CLOCKS_PER_SEC); #endif return 0; }
martes, 13 de marzo de 2012
507 - Jill Rides Again, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario