Submission #1018574

#TimeUsernameProblemLanguageResultExecution timeMemory
1018574vjudge1Autići (COCI22_autici)C++17
50 / 50
34 ms2016 KiB
#include <bits/stdc++.h>
#define int long long
#define endl ('\n')
constexpr long long inf = 1e18;
using namespace std;
bool vis[100001];
int32_t main(){
	int n,ans=0;
	cin>>n;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a.begin(),a.end());
	for(int i=1;i<n;i++){
		if(!vis[a[i].second])
			ans+=a[i].first;
			ans+=a[0].first;
			vis[a[i].second]=1;
			vis[a[0].second]=1;
	}
	cout<<ans;
}

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:17:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   17 |   if(!vis[a[i].second])
      |   ^~
Main.cpp:19:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   19 |    ans+=a[0].first;
      |    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...