제출 #1003783

#제출 시각아이디문제언어결과실행 시간메모리
1003783vjudge1Pastiri (COI20_pastiri)C++17
0 / 100
57 ms7248 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5*1e5+5; int dp[MAXN]; vector<int> v; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k; cin>>n>>k; for(int i = 1; i < n; i++){ int a,b; cin>>a>>b; } for(int i = 0; i < k; i++){ int x;cin>>x; v.push_back(x); } for(int i = k-1; i >= 0; i--){ dp[i] = dp[i+1]+1; if(i != k && (v[i+1]-v[i])%2 == 0)dp[i] = min(dp[i],dp[i+2]+1); } cout<<dp[0]<<"\n"; int i = 0; while(i < k){ if((v[i+1]-v[i])%2 == 1 || dp[i] == dp[i+1]+1){ cout<<v[i]<<" "; i++; }else{ cout<<v[i] + (v[i+1]-v[i])/2<<" "; i += 2; } }cout<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...