Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) B. Maxim Buys an Apartment
Posted 早知如此绊人心,何如当初莫相识。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) B. Maxim Buys an Apartment相关的知识,希望对你有一定的参考价值。
题意:有n个房子,k个有人住,问最少有多个,最多有多少个好的房子,好的房子定义:周围最少有一个房子有人住
思路:我们可以知道一个住了人的房子他最多产生2个好的房子(左右)所以判断k*3是否>=n
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+100; 4 typedef long long ll; 5 6 7 int main(){ 8 ll n,k; 9 cin>>n>>k; 10 int s1,s2; 11 if(k==n||k==0) {s1=0;s2=0;} 12 else s1=1; 13 if(n>=k*3){ 14 s2=k*2; 15 } 16 else s2=n-k; 17 cout<<s1<<" "<<s2<<endl; 18 }
以上是关于Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) B. Maxim Buys an Apartment的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D
Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A
codeforces比赛题解#854 CF Round #433 (Div.2)
Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) C. Planning