Submission #623705

#TimeUsernameProblemLanguageResultExecution timeMemory
623705Ferid20072020Autići (COCI22_autici)C++14
50 / 50
16 ms1624 KiB
#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)

Main.cpp: In function 'int main()':
Main.cpp:47:24: warning: 'x1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |         if(i != x && i != x1){
      |                      ~~^~~~~
Main.cpp:47:14: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |         if(i != x && i != x1){
      |            ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...