Submission #1003937

#TimeUsernameProblemLanguageResultExecution timeMemory
1003937vjudge1Pastiri (COI20_pastiri)C++17
8 / 100
210 ms6164 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...