# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003937 |
2024-06-20T20:21:18 Z |
vjudge1 |
Pastiri (COI20_pastiri) |
C++17 |
|
210 ms |
6164 KB |
#include<bits/stdc++.h>
using namespace std;
int n, k;
vector <int> v;
int main(){
cin >> n >> k;
for(int i = 1;i < n;i++){
int a, b;
cin >> a >> b;
}
for(int i = 1;i <= k;i++){
int x;
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
int res = v.size();
vector <int> ans = v;
int resp = 0;
vector <int> anss;
for(int i = 0;i < k;i++){
if(i < k-1 and (v[i+1]+v[i]) % 2 == 0){
anss.push_back((v[i+1]+v[i])/2);
resp++;i++;
}
else
{
resp++;
anss.push_back(v[i]);
}
}
if(res > resp){
ans = anss;
res = resp;
}
anss.clear();
reverse(v.begin(), v.end());
resp = 0;
for(int i = 0;i < k;i++){
if(i < k-1 and (v[i+1]+v[i]) % 2 == 0){
anss.push_back((v[i+1]+v[i])/2);
resp++;i++;
}
else {
resp++;
anss.push_back(v[i]);
}
}
if(res > resp){
ans = anss;
res = resp;
}
anss.clear();
cout << ans.size() << endl;
for(auto x : ans){
cout << x << ' ';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
344 KB |
Output is correct |
2 |
Correct |
154 ms |
348 KB |
Output is correct |
3 |
Correct |
140 ms |
348 KB |
Output is correct |
4 |
Correct |
210 ms |
6164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Sheep 3030 not protected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Sheep 128 not protected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
145 ms |
424 KB |
Sheep 54 not protected |
2 |
Halted |
0 ms |
0 KB |
- |