Submission #1003909

#TimeUsernameProblemLanguageResultExecution timeMemory
1003909vjudge1Pastiri (COI20_pastiri)C++17
8 / 100
279 ms40212 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MAXN = 5e5+5; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define pb push_back #define fr first #define sc second int n, k, sheep[MAXN]; vector<int> edges[MAXN]; int main() { cin >> n >> k; for(int i = 1, a, b; i < n; i++) { cin >> a >> b; edges[a].pb(b); edges[b].pb(a); } for(int i = 1; i <= k; i++) cin >> sheep[i]; if(n==0) { cout << "0\n"; } else { sort(sheep+1, sheep+1+k); vector<int> ans; for(int i = 1; i <= k; i++) { if(i == k) { ans.pb(sheep[i]); break; } if((sheep[i+1] + sheep[i]) % 2 == 0)ans.pb((sheep[i+1] + sheep[i])/2), i++; else ans.pb(sheep[i]); } cout << sz(ans) << "\n"; for(int it : ans) cout << it << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...