Submission #620086

# Submission time Handle Problem Language Result Execution time Memory
620086 2022-08-02T22:31:55 Z mmk Prosjek (COCI18_prosjek) C++14
50 / 50
1 ms 304 KB
#include<bits/stdc++.h>
using namespace std;
vector<double> v;
bool cmp(double a, double b)
{
    return a>b;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        double aux;
        scanf("%lf",&aux);
        v.push_back(aux);
    }
    while(v.size()!=1)
    {
        sort(v.begin(),v.end(),cmp);
        double aux=0;
        aux+=v.back();
        v.pop_back();
        aux+=v.back();
        v.pop_back();
        aux=aux/2;
        //printf("%lf\n",aux);
        v.push_back(aux);
    }
    printf("%.6lf",v[0]);
}

Compilation message

prosjek.cpp: In function 'int main()':
prosjek.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
prosjek.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lf",&aux);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct