C++一次过
#include <iostream>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
int t, maxp = -1, minp = 101, tm;
long long res = 0l;
for(int i = 0; i < n; i++)
{
scanf("%d", &t);
res += t;
if (maxp < t) maxp = t;
if (minp > t) minp = t;
tm = maxp + minp;
if (i >= 2)
{
printf("%.2f\n", (double)(res-tm)/(i-1));
}
}
return 0;
}
Java死活只有一对4错5MLEhttps://www.luogu.com.cn/record/194847381
import java.io.*;
public class Main {
public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
public static PrintWriter ou = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException {
int n = Integer.parseInt(in.readLine());
String str[] = in.readLine().split("[ ]+");
long res = 0;
int max = -1, min = 101, tm, t;
for (int i = 0; i < n; i++){
t = Integer.parseInt(str[i]);
res += t;
if (max < t) max = t;
if (min > t) min = t;
tm = max + min;
if (i >= 2)
{
out.write(String.format("%.2f\n", (double)(res-tm)/(i - 1)));
}
}
out.flush();
in.close();
out.close();
}
}