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) B. Maxim Buys an Apartment
names style mes using con iad 有一個 sed 多少 題意:有n個房子,k個有人住,問最少有多個,最多有多少個好的房子,好的房子定義:周圍最少有一個房子有人住 思路:我們可以知道一個住了人的房子他最多產生2個好的房子(左右)所以判斷k*3是否&g
Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D
cost iso %d min cti oos opera all find Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty a
Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) C. Ordering Pizza
scanf col size class sql == 我們 個人 ++ 題意:有2種pizzaA和B,有n個人,每塊pizz分為S片,給出每個人需要吃s片,吃一片A獲得x的幸福,吃一片B獲得y的幸福,問在購買最少的Pizza的前提下獲得的最大幸福值 思路:註意每個人可同時
Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E. Buy Low Sell High
amp base multiset ret pac multi 刪掉 股票 ems 題意:一些股票的價格,我們可以選擇買進賣出,但一天只有一個操作,問最大盈利 思路:對於當天,如果賣出的話&&之前有比他小的,我們肯定是找個最小那天的買進,但又不知道現在賣是不
Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2)
eno possible ane following ces force ros spec test case A. Between the Offices time limit per test 2 seconds memory limit per test
Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E. Buy Low Sell High [貪心 II][數據結構 I]
fin 想想 ima 直接 圖片 test 只需要 數據結構 lan 題目:http://codeforces.com/contest/867/problem/E 題意:模擬股票操作,每天只能買一只股票或者賣一只股票或者什麽也不做,求最大利潤。 題解:仔細想想是非常簡單的
Codeforces Round #454 (Div. 2, based on Technocup 2018 Elimination Round 4) D. Seating of Students [模擬]
tdi ati cto res link rec 代碼 答案 stack 題意:給一個n行m列的矩陣,原矩陣按數字順序從第一行開始向後填充,尋找一種方案使得原矩陣中相鄰的數字在新矩陣中都不相鄰。 分析:沒有什麽技術含量的一道構造題,試試就可以發現方案,很多人是用隨機化過的
Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)
force return lose codeforce code 範圍 nal sin -- A、B都是暴力搞一搞。 A: 1 #include<bits/stdc++.h> 2 #define fi first 3 #define se second
Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round) D. Peculiar apple-tree
pear mit sub vector mes IT nta sim 之間 D. Peculiar apple-tree time limit per test 1 second memory limit per test 256 megabytes input
D. Arpa and a list of numbers Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)
bsp tdi ble mat sum i++ amp ext com http://codeforces.com/contest/851/problem/D 分區間操作 1 #include <cstdio> 2 #include <cstdl
Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) C. Vasya and Golden Ticket
足夠 scan property ++ inter digits pos 通過 題意 C. Vasya and Golden Ticket time limit per test 1 second memory limit per test 256 megabytes
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) D. Minimum path(字典序)
https://codeforces.com/contest/1072/problem/D 題意 給你一個n*n充滿小寫字母的矩陣,你可以更改任意k個格子的字元,然後輸出字典序最小的從[1,1]到[n,n]的路徑(1<=n<=2000) 思路 我的 定義dp[i][j]為
Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3)
A. Kitchen Utensils 找到k在餐具中的大倍數 #include<bits/stdc++.h> #include<vector> using namespace std; const int maxn=105; int a[maxn]; int mai
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)D(思維,DP,字串)
#include<bits/stdc++.h>using namespace std;char c[2007][2007];char ans[4007];int s[2007][2007];int main(){ memset(s,-1,sizeof(s));&
【Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) C. Cram Time】 貪心
C. Cram Time 題意 給你兩個數a,b,用a,b分別構造兩個序列A,B, 要求A序列的和小於a,B序列的和小於b 而且A序列中和B序列中每個數最多在兩個序列中出現一次 要是最終的兩個序列的長度和最大,輸出兩個序列 做法
【Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) D. Minimum path】dp+滾動陣列
D. Minimum path 題意 給你一個字元矩陣,起點在左上角,每次可以向右或者向下走,可以改變這個字元矩陣中的k個字元,是這個路徑構成的字串字典序最小。 做法 由於可以改變k個字元,那麼肯定是找到一條路徑,前面至少有k項為a, 後面按照字典序選擇路徑就可以。 所
【Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)】 A.B.C.D
前言 在晚上的div2之前開啟的這場,但是自己頭腦貌似不太清醒,全程在寫bug,而且B題不知道自己在寫啥,寫了一百多行?,C也寫了好多bug導致最後的D一眼思路但是沒寫完。希望晚上狀態不要這麼差!QWQ A. Golden Plate 題意 給你一個h*w的長方形邊框,
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)D(思維,DP,字符串)
bsp mes () print urn getch %d ase etc #include<bits/stdc++.h>using namespace std;char c[2007][2007];char ans[4007];int s[2007][2007
Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) A-D題解
比賽傳送門 A. In Search of an Easy Problem 最樸素的解法,掃一邊有木有1。。。。。 #include<bits/stdc++.h> #define rep(i,j,k) for(int i=j;i<=k;i++) usi
Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1)
比賽傳送門 A題.水題 #include<bits/stdc++.h> using namespace std; int main() { int t; scanf("%d",&t); bool flag=false;