pat 1012 测试点7过不去

#include<iostream>
#include<math.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[1001];
	int b[501];
	int count1;
	for (count1 = 0; count1 < n; count1++) {
		cin >> a[count1];
	}
	int count2;
	int k = 0, l = 0, m = 0, p = 0;//p给A1计数,k给a2计数,l给a4计数,m给a5计数
	int c = 0, d = 0, e = 0;
	double f = 0;
	for (count2 = 0; count2 < n; count2++) {
		if (a[count2] % 5 == 0) {
			if (a[count2] % 2 == 0) {
				c = c + a[count2];
				p++;
			}
		}
		//------------------
		else if (a[count2] % 5 == 1) {
			d = d + a[count2] * pow(-1, k);
			k++;
		}
		//------------------
		else if (a[count2] % 5 == 2) {
			e++;
		}
		//-----------------
		else if (a[count2] % 5 == 3) {
			l++;
			f = f + a[count2];
		}
		//-----------------
		else if (a[count2] % 5 == 4) {
			b[m] = a[count2];
			m++;
		}
	}
	/*cout << c << " " << d << " " << e << " " << (f / l) << " ";*/
	//可能出现运算完之后结果刚好为0的情况
	if (p == 0) { cout << "N" << " "; }
	else { cout << c << " "; }
	if (k == 0) { cout << "N" << " "; }//d相减之后为零的情况
	else { cout << d << " "; }
	if (e == 0) { cout << "N" << " "; }
	else { cout << e << " "; }
	if (l == 0) { cout << "N" << " "; }
	else { printf("%.1lf", (f / l * 1.0) + 0.05); cout << " "; }//需要4舍5如
	int count3;
	int max = 0;
	if (n == 1) {
		if (a[0] % 5 == 4) {
			max = a[0];
		}
	}//n==1的时候不会进循环;
	for (count3 = 0; count3 <m; count3++) {
		if (b[count3] > b[count3 + 1]) {
			max = b[count3];
		}
		else {
			max = b[count3 + 1];
		}
	}
	if (m == 0) { cout << "N"; }
	else { cout << max << endl; }

}