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 }
时间: 2024-10-12 22:48:55

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

Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively num

Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A. Fraction

题意:2个数A,B,A+B==n,并且A<B,问最大的A/B是多少,A与B互质 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 int n; 9 cin>>n; 10 for(int i=n/2;i>=1;i--){ 11 int y=n-i; 12 if(__gcd(i,y)==1){

Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) C. Planning

题意:给出每个航班花费和顺序,求新顺序使得花费最少 思路:肯定是花费最大的先决定,二分一下 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+100; 4 typedef long long ll; 5 6 struct node{ 7 ll x; 8 int id; 9 ll yy; 10 }a[300004]; 11 bool cmp(node p,node q){ 12 return p.x>q.x

Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A

Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction  is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its numerator

【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) A】Palindrome Dance

[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] i从1..n/2循环一波. 保证a[i]和a[n-i+1]就好. 如果都是2的话填上min(a,b)*2就好 其他情况跟随非2的. [代码] #include <bits/stdc++.h> #define LL long long #define rep1(i,a,b) for (int i = a;i <= b;i++) #define rep2(i,a,b) for (int i = a;i >= b;i--

Codeforces Round #433 (Div. 1) D. Michael and Charging Stations(dp)

题目链接:Codeforces Round #433 (Div. 1) D. Michael and Charging Stations 题意: 一个人每天要加油,1种为1000,1种为2000,如果付全额,会得到10%的回扣放在卡上. 如果卡上有剩余的回扣,可以拿来抵现金.问n天最少需要花多少钱. 题解: 很直观的一个dp就是考虑dp[i][j],表示第i天卡上剩余回扣为j的最小花费. 将所有的数除以100后,j其实是小于40的,严格的说是小于30,官方题解有个证明. 因为卡上不可能积累很多的

DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad

题目传送门 1 /* 2 DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <cstring> 7 #include <cmath> 8 #include <algorithm> 9 #include <vector> 10 #include <map> 11 #include

Codeforces Round #433 (Div. 2)

题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 int gcd(int a,int b){re

Codeforces Round #500 (Div. 2) [based on EJOI]

Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define IT set<node>::iterator 6 #def