Submission #696614

# Submission time Handle Problem Language Result Execution time Memory
696614 2023-02-07T01:23:13 Z LeDaiKing Autići (COCI22_autici) C++14
50 / 50
17 ms 988 KB
#include<bits/stdc++.h>

using namespace std;

#define NMOD 3
#define ll long long
#define fi first
#define se second
#define pb push_back
#define log 17
#define mask(i) (1ll << (i))
#define setp(x) setprecision(x)
#define ALL(v) v.begin(), v.end()
#define ck(n, i) (((n) >> (i)) & 1) 
#define getbit(x) __builtin_popcount(x)

const double PI = acos(-1);
const long long MOD = 1e9 + 7;
const long long MOD1 = 998244353;
const long long MODo = 123456789;

const int oo = 1e9;
const long long oo15 = 1e15, oo18 = 1e18+3, oooo = 922372036854775807;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[100005];

void solve() 
{
	int n;
	cin >> n;

	if (n == 1)
	{
		cout << 0; return;
	}

	ll sum = 0;

	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}

	sort(a + 1, a + 1 + n);

	sum += 1ll*(n - 2)*a[1];

	cout << sum;

}

int main() 
{   
   
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);  
    int testcase = 1;
    //cin >> testcase;
    while(testcase--)
        solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 724 KB Output is correct
3 Correct 13 ms 844 KB Output is correct
4 Correct 11 ms 936 KB Output is correct
5 Correct 11 ms 924 KB Output is correct
6 Correct 10 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 724 KB Output is correct
3 Correct 13 ms 844 KB Output is correct
4 Correct 11 ms 936 KB Output is correct
5 Correct 11 ms 924 KB Output is correct
6 Correct 10 ms 896 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 5 ms 724 KB Output is correct
22 Correct 16 ms 968 KB Output is correct
23 Correct 13 ms 952 KB Output is correct
24 Correct 15 ms 888 KB Output is correct
25 Correct 16 ms 852 KB Output is correct
26 Correct 15 ms 884 KB Output is correct
27 Correct 17 ms 900 KB Output is correct
28 Correct 15 ms 880 KB Output is correct
29 Correct 16 ms 988 KB Output is correct
30 Correct 14 ms 904 KB Output is correct