Submission #17538652


Source Code Expand

Copy
#include <bits/stdc++.h>
typedef unsigned long long int ll;
#define Need_For_Speed(activated) ios_base::sync_with_stdio(false);cin.tie(0);//cout.tie(0);system("cls");
#define MOD 1000000007
#define en '\n'
#define sp " "

using namespace std;



int main()
{
    
    Need_For_Speed(activated);

    ll n;
    cin >> n;
    ll i, md = 0, cd = INT_MIN;
    long double ed = 0;
    ll x;

    for(i = 0; i < n; i++) {
        cin >> x;
        md += abs(x);
        cd = max(cd, x);
        ed += (abs(x) * abs(x)); //ed += (abs(x) * abs(x) * 1LL); this is no good
    }

    ed = sqrt(ed);

    cout<<md<<en;
    cout<<fixed<<setprecision(15)<<ed<<en;
    cout<<cd<<en;

    

    return 0;
}

Submission Info

Submission Time
Task A - box
User N0ticeMeSenpai
Language C++ (GCC 9.2.1)
Score 0
Code Size 731 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:20: error: call of overloaded ‘abs(ll&)’ is ambiguous
   25 |         md += abs(x);
      |                    ^
In file included from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ./Main.cpp:1:
/usr/include/stdlib.h:837:12: note: candidate: ‘int abs(int)’
  837 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from ./Main.cpp:1:
/usr/include/c++/9/bits/std_abs.h:103:3: note: candidate: ‘constexpr __float128 std::abs(__float128)’
  103 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:85:3: note: candidate: ‘constexpr __int128 std::abs(__int128)’
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
./Main.cpp:27:21: error: call of overloaded ‘abs(ll&)’ is ambiguous
   27 |         ed += (abs(x) * abs(x)); //ed += (abs(x) * abs(x) * 1LL); this is no good
      |                     ^
In file included from /usr/in...