# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
696227 |
2023-02-06T02:14:50 Z |
vjudge1 |
Autići (COCI22_autici) |
C++14 |
|
1000 ms |
2392 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int ar[n+5]={};
int mx[n+5]={};
for(int i=0;i<n;i++){
cin>>ar[i];
}
priority_queue<pair<int,int> ,vector<pair<int,int> >,greater<pair<int,int> > >pq;
for(int i=1;i<n;i++){
pq.push({ar[0]+ar[i],i});
mx[i]=ar[0]+ar[i];
}
int vis[n+5]={};
long long ans=0;
int i=n-1;
while(i){
int a=pq.top().first;
int b=pq.top().second;
pq.pop();
if(vis[b]==0){
i--;
//cout<<b<<" "<<a<<" "<<i<<endl;
ans+=a;
vis[b]=1;
for(int j=0;j<n;j++){
if(vis[j]==0){
if(ar[b]+ar[j]<mx[j]){
mx[j]=ar[b]+ar[j];
pq.push({mx[j],j});
}
}
}
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1086 ms |
2392 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 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 |
324 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
324 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1086 ms |
2392 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |