# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1045014 |
2024-08-05T15:38:30 Z |
vjudge1 |
Pastiri (COI20_pastiri) |
C++17 |
|
197 ms |
42676 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 500005
#define fi first
#define se second
vector<int> v[lim];
int n,k;
int dp[lim][2];
int dizi[lim];
int yol[lim];
inline int f(int sira,int kim){
//cout<<sira<<" "<<kim<<endl;
if(sira>=k+1)return 0;
if(~dp[sira][kim])return dp[sira][kim];
int cev=LLONG_MAX;
if(cev>f(sira+1,1)+1){
cev=f(sira+1,1)+1;
yol[sira]=1;
}
int tut=dizi[sira]+dizi[sira+1],ek=1;
if(tut&1)ek++;
if(sira<=k-1){
if(cev>f(sira+2,0)+ek){
cev=f(sira+2,0)+ek;
yol[sira]=2;
}
}
return dp[sira][kim]=cev;
}
int32_t main(){
faster
memset(dp,-1,sizeof(dp));
cin>>n>>k;
FOR{
if(i==1)continue;
int a,b;cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=1;i<=k;i++){
cin>>dizi[i];
}
cout<<f(1,1)<<endl;
/*
for(int i=1;i<=k;i++){
cout<<yol[i]<<" ";
}
cout<<endl;*/
set<int> st;
int tut=1;
while(tut<k){
//cout<<tut<<" "<<" "<<yol[tut]<<" "<<st.size()<<endl;
/*for(auto x:st)cout<<x<<" ";
cout<<endl;*/
if(yol[tut]==1){
st.insert(tut);
tut++;
}
else{
int gec=dizi[tut+1]+dizi[tut];
if(gec&1){
st.insert(gec/2);
st.insert(gec/2+1);
}
else{
st.insert(gec/2);
}
tut+=2;
}
}
for(auto x:st){
cout<<x<<" ";
}
cout<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
72 ms |
41820 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
23640 KB |
Sheep 856 not protected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
23644 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
197 ms |
42676 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |