Submission #1003909

# Submission time Handle Problem Language Result Execution time Memory
1003909 2024-06-20T19:50:43 Z vjudge1 Pastiri (COI20_pastiri) C++17
8 / 100
279 ms 40212 KB
#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 time Memory Grader output
1 Correct 199 ms 28808 KB Output is correct
2 Correct 172 ms 28496 KB Output is correct
3 Correct 201 ms 35140 KB Output is correct
4 Correct 279 ms 40212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 12892 KB Sheep 3030 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12892 KB Sheep 128 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 239 ms 28820 KB Sheep 54 not protected
2 Halted 0 ms 0 KB -