# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623705 | Ferid20072020 | Autići (COCI22_autici) | C++14 | 16 ms | 1624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define ins insert
#define pb push_back
#define MOD 10000
#define oo 1000000001
#define pii pair<int , int>
#define pll pair<ll , ll>
#define pli pair<ll , int>
#define pil pair<int , ll>
int a[100001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n , x , x1;
ll min1 = oo , min2 = oo;
cin >> n;
if(n == 1){
cout << 0;
return 0;
}
for(int i=1 ; i<=n ; i++){
cin >> a[i];
if(min1 > a[i]){
min1 = a[i];
x = i;
}
}
for(int i=1 ; i<=n ; i++){
if(min2 > a[i] && i != x){
min2 = a[i];
x1 = i;
}
}
ll cem = min1 + min2;
for(int i=1 ; i<=n ; i++){
if(i != x && i != x1){
cem += a[i] + min1;
}
}
cout << cem;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |