|
|
back to boardWA# 6 What is wrong? Posted by Joe 6 Feb 2015 04:08 #include <stdio.h> int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif int n; scanf("%d", &n); long *sections = new long[n]; for (int i = 0; i < n; i++){ scanf("%ld", §ions[i]); } if (n==3){ printf("%ld %d", sections[0] + sections[1] + sections[2], 2); } else{ int i = 0; int maxpoint = i; while (i + 3 < n){ int j = i + 1; if (sections[i] + sections[i+1] + sections[i+2] < sections[j] + sections[j+1] + sections[j+2]){ maxpoint = j; } i++; } printf("%ld %d", sections[maxpoint] + sections[maxpoint+1] + sections[maxpoint+2], maxpoint+2); } return 0; } Re: WA# 6 What is wrong? Posted by QLRS 5 Mar 2016 02:00 Input: 5 1 2 3 4 5 Output: 12 4 ENG: Read carefully the terms. Numbers do not necessarily have to be the same. (Google Translate) RUS: Внимательно читайте условие. Числа не обязательно должны быть одинаковыми. Re: WA# 6 What is wrong? You should not compare sum with the previous sum, but the max sum. Considering sequence: 1 6 6 6 1 1 1 2 2 2 |
|
|