Submission #696604

# Submission time Handle Problem Language Result Execution time Memory
696604 2023-02-07T01:11:46 Z anhduc2701 Autići (COCI22_autici) C++17
10 / 50
14 ms 1492 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define eb emplace_back
#define PI 3.14159265359
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define task "tnc"  
typedef long long ll;
const ll INF=1e18;
const int maxn=1e6+5;
const int mod=1e9+7;
const int mo=998244353;
using pi=pair<ll,ll>;
using vi=vector<ll>;
using pii=pair<pair<ll,ll>,ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
int a[maxn];
signed main()
{
	cin.tie(0),cout.tie(0)->sync_with_stdio(0);
    //freopen(task".inp" , "r" , stdin);
    //freopen(task".out" , "w" , stdout);
    cin>>n;

   	int sum=0;
   	for(int i=1;i<=n;i++){
   		cin>>a[i];
   		sum+=a[i];
    }
    if(n==1){
    	cout<<0;	
    }
    else{
    	sort(a+1,a+1+n);
    	sum*=2;
    	sum-=a[n];
    	sum-=a[n-1];
    	cout<<sum;
	}
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 6 ms 1196 KB Output is correct
3 Correct 13 ms 1440 KB Output is correct
4 Correct 10 ms 1432 KB Output is correct
5 Correct 12 ms 1492 KB Output is correct
6 Correct 14 ms 1336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 ms 344 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 6 ms 1196 KB Output is correct
3 Correct 13 ms 1440 KB Output is correct
4 Correct 10 ms 1432 KB Output is correct
5 Correct 12 ms 1492 KB Output is correct
6 Correct 14 ms 1336 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 1 ms 344 KB Output is correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Halted 0 ms 0 KB -