poj3468电池的寿命

来源:互联网 发布:js移除style属性 编辑:程序博客网 时间:2024/04/26 18:38
#include <iostream>#include <stdio.h>#include <fstream>#include <string.h>#include <iomanip>using namespace std;int main(){//freopen("1.txt","r",stdin);int n;double sumPower;int longestPower;int battery[1001];while(scanf("%d",&n)!=EOF){sumPower = 0;longestPower = 0;memset(battery,0,sizeof(battery));for(int i = 1; i <= n; ++i){scanf("%d",&battery[i]);if(longestPower < battery[i])longestPower = battery[i];sumPower += battery[i];}if(longestPower >= sumPower / 2){printf("%.1lf\n",(double)(sumPower - longestPower));continue;} elseprintf("%.1lf\n",sumPower/2.0);}return 0;}