Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<iostream> #include<algorithm> using namespace std; int main(){ int n,m; while(cin>>n>>m,n){ int veg[n]; for(int i=0;i<n;i++)cin>>veg[i]; sort(veg,veg+n,greater<int>()); int res=0; for(int i=0;i<n;i++){ if((i+1)%m==0)continue; res+=veg[i]; } cout << res << endl; } ...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<iostream> #include<algorithm> using namespace std; int n, m, x[1000000]; long long sum1, sum2; int main() { while (true) { sum1 = 0; sum2 = 0; cin >> n >> m; if (n == 0 && m == 0) { break; } for (int i = 0; i < n; i++) { cin >> x[i]; sum1 += x[i]; } sort(x, x + n); for (int i = n - m; i >=...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<iostream> #include<algorithm> #include<functional> using namespace std; int main(){ int n, m; while(cin >> n >> m, n || m){ int price[10010]; int ans = 0; for(int i=1; i <= n; i++) cin >> price[i]; sort(price+1, price+n+1, greater<int>()); for(int i=1; i <= n; i++){ if(i % m == 0) continue...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,m; while(cin >> n >> m , n + m){ int yasai[1000] = {0}; for(int i = 1 ; i <= n ; i++){ cin >> yasai[i]; } sort(yasai,yasai+(n+1),greater<int>()); for(int i = n ; i >0 ; i--){ yasai[i] = yasai[i-1]; ...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<iostream> #include<queue> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) using namespace std; int main(){ int n,m,dt; while(1){ cin>>n>>m; if(!(n&&m))break; priority_queue<int> que; rep(i,n){cin>>dt;que.push(dt);} int cnt=0,sum=0; while(!que.empty()){ cnt++; if(cnt!=...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner in = new Scanner(System.in)) { solve(in); } } private static void solve(Scanner in) { // n m // p1 p2 ... pn while (true) { ...
JAVA
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int main() { int n, m; int veg[1024]; int sum; while (1){ sum = 0; scanf("%d%d", &n, &m); if (n == 0 && m == 0){ break; } for (int i = 0; i < n; i++){ scanf("%d", &veg[i]); } sort(veg, veg + n); reverse(veg, ...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <iostream> #include <algorithm> using namespace std; int main() { int n, m; int data[1000]; int sum; while(1) { cin >> n >> m; if(n == 0 && m == 0) break; for(int i = 0; i < n; i++) { cin >> data[i]; } sort(data, data+n); sum = 0; int i = n-1; while(1) { f...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <bits/stdc++.h> using namespace std; #define for_(i,a,b) for(int i=(a);i<(b);++i) int n, m, p[1010]; int main() { while (cin >> n >> m, n) { for_(i,0,n) cin >> p[i]; sort(p, p + n, greater< int >()); int ans = 0, cnt = 1; for_(i,0,n) { if (cnt == m) { cnt = 1; } else { ++cnt;...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<stdio.h> int main(void) { int a,s,d[2000],f,g,h,i,j; scanf("%d %d",&a,&s); while(a!=0&&s!=0){ for(i=1;i<=a;i++){ scanf("%d",&d[i]); } for(i=1;i<=a;i++){ for(j=i;j<=a;j++){ if(d[i]<d[j]){ f=d[i]; d[i]=d[j]; d[j]=f; } } } g=0; h=0; for(i=1;i<=a;i++){ if(g==s-1)...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
while True: n, m = map(int, input().split()) if n == 0: break plst = sorted(list(map(int, input().split())), reverse=True) s = sum(plst) for i in range(m - 1, n, m): s -= plst[i] print(s)
PYTHON3
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
# AOJ 0227: Thanksgiving # Python3 2018.6.24 bal4u while 1: n, m = map(int, input().split()) if n == 0: break p = list(map(int, input().split())) p.sort(reverse=True) ans = 0 for i in range(1, n+1): if i % m: ans += p[i-1] print(ans)
PYTHON3
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(void){ int n,m; while(cin>>n>>m, n||m){ vector<int> p(n); for(int i=0;i<n;++i) cin>>p[i]; sort(p.begin(), p.end(), greater<int>()); int sum=0,tmp=0; for(int i=0;i<n-(n%m);++i){ tmp+=p[i]; if(i%m=...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int main(void) { while (1) { int n, m, p[1000], sum = 0; cin >> n >> m; if (n == 0 && m == 0)break; for (int i = 0; i < n; i++) { cin >> p[i]; sum += p[i]; } sort(p, p + n); for (int i = n - m; i >= 0; i -= m) { s...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <iostream> #include <algorithm> using namespace std; int main() { int N,M; while(cin >> N >> M,(N||M)) { int a[1000],ans=0; for(int i=0; i<N; i++) { cin >> a[i]; ans+=a[i]; } sort(a,a+N); reverse(a,a+N); for(int i=M-1; i<N; i+=M) ans-=a[i]; cout << ans << endl; } }
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <iostream> #include <queue> #include <algorithm> using namespace std; int main(){ int m,n,a,b,sum, temp; int ans; priority_queue<int> que; while(1) { sum = 0; cin>>n>>m; if(n == 0 && m == 0){ break; } for(int i = 0; i<n; ++i){ cin>>a; que.push(a); } f...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n, m; while ((n = in.nextInt()) != 0 && (m = in.nextInt()) != 0) { int[] yasai = new int[n]; for (int i = 0; i < n; i++) { yasai[i] = in.nextInt(); ...
JAVA
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include<iostream> #include<cmath> #include<algorithm> using namespace std; int main(){ int m,n; int b[1001]; while(cin >> n >> m,m || n){ int total=0; int k=n/m; for(int i=0;i<n;i++) cin >> b[i]; sort(b,b+n); for(int i=1;i<=n;i++){ if(i%m) total+=b[n-i]; } cout << total << end...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
#include <iostream> #include <vector> #include <algorithm> int main(){ int n,m; //n:buy count m:pack count while(std::cin >> n >> m){ if(n == 0 && m == 0) break; std::vector<int> price; price.resize(n); for(int i=0; i<n; ++i){ std::cin >> price[i]; } std::sort(price.begin(), price.end(), s...
CPP
p00227 Thanksgiving
As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloomed with a...
7
0
while True: try: __, m = (lambda row: [int(row[i]) for i in range(len(row))])(input().split()) price = sorted(list(map(int, input().split())), reverse=True) print(str(sum([price[i] for i in range(len(price)) if (i+1)%m != 0]))) except: break
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include<vector> #include<algorithm> #include<string> #include<map> #include<set> #include<stack> #include<queue> #include<math.h> using namespace std; typedef long long ll; #define int long long typedef vector<int> VI; typedef pair<int, int> pii; #define fore(i,a) for(auto &i:a) #define REP(i,n) fo...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int res = 0; int row = 1; int w = 0; while ( n >= row ) { // cout << w << " " << row << endl; if ( row*k >= w ) { ++res; w += row; n -= row; } else if ( n >= row+1 ) ++row; else break; } ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
n,k = map(int, input().split()) res = 0 row = 1 w = 0 while n >= row : if row*k >= w : res += 1 w += row n -= row elif n >= row+1 : row += 1 else : break print(res)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
import java.io.*; import java.util.*; class Main { void solve(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(); int res = 0; int row = 1; int w = 0; while ( n >= row ) { if ( row*k >= w ) { ++res; w += row; n -= row; } else if ( n >= row+1 ) ++row; e...
JAVA
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; int N, K; int main() { int h, m; double rest; h = 1; cin >> N >> K; rest = N; while (true) { m = rest / (K + 1) * K; if (m == 0) { break; } ++h; rest = m; } cout << h << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include "bits/stdc++.h" #define rep(var,cnt) for(int (var)=0; (var)<(cnt); ++(var)) using namespace std; using int64 = int64_t; using pi=pair<int,int>; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const Mod...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
N,K = map(int, input().split()) t = n = a = 1 while True: n = (K+a-1)//K a += n; if N < a: break t += 1 print(t)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; int main(){ int N, K; cin >> N >> K; int n = N; int sum = 0; int ans = 0; while (n >= 0) { int row = (sum + K - 1) / K; row = max(row, 1); // cout << n << " " << sum << " " << ans << " " << row << endl; if (row > n) ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include <algorithm> using namespace std; class Solver { public: static void solve() { int n, k; cin >> n >> k; int now = 1; n--; int sum = 1; while (true) { int need = sum / k; if (sum % k > 0)need++; if (n < need)break; now++; sum += need; n -= need; } cout ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int count = sc.nextInt(); int strength = sc.nextInt(); int total = 1; int size = 1; count--; while (true) { int x = (total + strength - 1) / strength; if (count >= x) { ...
JAVA
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; int main(void) { int N, K; cin >> N >> K; int cnt = 0; while(N>0){ int x = (N-1)/(K+1)+1; N -= x; cnt++; } cout << cnt << endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
n, k = map(int, input().split()) ans = 1 w = 1 while n-w>0: blw = (w+k-1)//k w += blw if n-w>=0: ans+=1 print(ans)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; int main(void){ int n, k; cin >> n >> k; int x = 1, y = 0, sum = 0; while(1){ if(sum + x > n) break; if(sum > k * x){ x = sum / k; if(sum % k > 0) x++; } else sum += x, y++; } cout << y << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <utility> #include <cstring> #include <iomanip> #include <numeric> #include <cmath> #include <queue> #include <map> using namespace std; typedef long long ll; const int INF = 1<<30; const int MOD = 1e9 + 7; cons...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; #define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20); #define int long long #define gcd __gcd #define all(x) (x).begin(), (x).end() const int INF = 1e18, MOD = 1e9 + 7; template<class T> bool chmax(T& a, T b){return (a = max...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; int main(){ int n,k,sum=0,now=1,ans=0; cin>>n>>k; for(;;){ if(sum+now>n)break; else if(sum<=now*k)sum+=now,ans++; else now++; } cout<<ans<<endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; int ans = 0, sum = 0; while(n >= max(1LL, (sum + k - 1) / k)) { ans += 1; const ll add = max(1LL, (sum + k - 1) / k); sum += add; n -= add; } cout << ans << en...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=x;i<y;i++) #define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl; #define pprint(a,m,n) rep(j,0,m){ print(a[j],n); } const int mod = 1e9+7; const int size=1e5; const int INF=1e9; int main(){ int N,K;cin>>N>>K; int sum=1;int i=1; ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include <algorithm> #include <vector> using namespace std; int judge(int n,int k,int amari){ if(amari<=1){ return 0; } else { for(double i=2;;i++){ if((n-amari)/i<=k) return i; if(amari<=i) return 0; } } } int main(){ int n,k; cin >> n >> k; int num=k+1; in...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; int putBlocks(int N, int K) { if (N == 1) return 1; else { int most_under = 1;//最下段のブロックの数 int count = N;//注目塔の高さ while ((((double)count - 1) / (double)most_under) > K) {//注目塔の最下段の強度を判定 most_under++; count--;//塔の高さを減らす(最下段へ) } return 1 + putBlocks(cou...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include "bits/stdc++.h" using namespace std; int main() { long long N, K, NOW = 1, ANS = 0; cin >> N >> K; while (N >= NOW) { NOW += (NOW + K - 1) / K; ANS++; } cout << ANS << endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE signed main(){ Int n,k; cin>>n>>k; Int ans=1,sum=1; n--; while(1)...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using LL = long long; using namespace std; int main(){ int N,K;cin >> N >> K; LL ans = 1; LL weight = 1; LL ins = 0; N--; while(N != 0){ // cout<<weight<<endl; if(ins == 0){ ins++; N--; }else if(1.0*weight/ins <= K)...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#define _AOJ_ #include "bits/stdc++.h" using namespace std; typedef long long i64; #define rep(i,n) for(int i=0;i<n;++i) #define REP(i,a,b) for(int i=a;i<b;++i) #define all(c) c.begin(),c.end() //define pfs,bellmanford,etc. int main(){ i64 n,k;cin>>n>>k; i64 s=1,ans=1; vector<i64>a(1,1); while(s<=n){ a.push_bac...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) int main() { int n,k,t=0,ans=0,u=1; cin >> n >> k; while (true) { if (n-t<u) break; if (u*k>=t) {t+=u;ans++;} else {u++;continue;} } cout << ans << endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
import math n, k = map(int, input().split()) ret = 1 acc = 1 while True: want = math.ceil(acc / k) if(want+acc > n): break acc += want ret += 1 print(ret)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> mp; #define inf 1e9 int main(){ int n,k; cin>>n>>k; int sum = 0; int h = 0; int y = 1; while(n-y>=0){ // cout<<n<<endl; if((double)sum/y <= k){ sum+=y; n-=y; h++; }else{ while( ( (double) sum/y) > (double...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef pair<int,int>P; int main(){ int n,K;cin>>n>>K; int cnt=1,i=1; for(;;i++){ int need=(cnt+K-1)/K; if(cnt+need>n)break; cnt+=need; } cout<<i<<endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; typedef pair<int, ll> pli; typedef pair<double,double> pdd; #define SQ(i) ((i)*(i)) #define MEM(a, b) memset(a, (b), sizeof(a)) #define SZ(i) int(i.size()) #define FOR(i, ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<iostream> using namespace std; int main(){ int N, K, count = 0, sum = 0, num = 1; cin>>N>>K; for(;;){ if(sum > num*K){ num = (sum+K-1)/K; //cout<<"num = "<<num<<endl; } N -= num; sum += num; if(N < 0)break; count++; //cout<<count<<" "<<sum<<" "<<num<<endl; } cout<<count<<endl; ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; int main(){ int N ,K; cin >> N >> K; int ans = 1; int wei = 1; N--; while(N > 0){ int n = ceil((double)wei / (double)K); if(N >= n) ans++; wei += n; N -= n; } cout << ans << endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using P = pair<llong, llong>; #define BE(x) x.begin(), x.end() const llong inf = llong(1e18)+7; const llong mod = 1e9+7; int main(){ llong N, K; cin >> N >> K; llong now = 1, ans = 1; N--; while(true){ llong next...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<iostream> #include<cassert> using namespace std; int solve(int N, int K){ int t = 1; int n = 1; int a = 1; while(1){ n = (K+a-1)/K; a += n; if ( N < a ) return t; t++; } } int main() { int N, K; cin >> N >> K; int t = solve(N, K); cout << t << endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> #include <assert.h> using namespace std; int main() { int n, k; cin >> n >> k; n--; int sum = 1, ans = 1; while ((sum + k - 1) / k <= n) { n -= (sum + k - 1) / k; sum += (sum + k - 1) / k; ans++; } cout << ans << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 99999999999999999 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; int main(){ int N,K; scanf("%d %d",&N,&K); int ans = 1,upper = 1; int rest = N-1,need; while(t...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int remove = 0, count = 0; if( n <= k + 1 ) { cout << n << endl; } else { n -= k + 1; remove += k + 1; while( 1 ) { n -= ceil( static_cast<double>( remove ) / k ); remove += ceil( static_cast<double>( remove ) / k );...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <cstdio> #include <vector> #include <algorithm> #include <utility> bool valid(int N, int K, int x) { int wsum = 1; for (int i = 1; i < x; ++i) { int n = (wsum+K-1) / K; wsum += n; if (wsum > N) return false; } return wsum <= N; } int main() { int N, K; scanf("%d %d", &N, &K); int l...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<iostream> using namespace std; int main(){ int n, k; cin >> n >> k; k++; int ans = 0; while (n > 0) { int m = (n + k - 1) / k; n -= m; ans++; } cout << ans << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long base = sc.nextLong(), K = sc.nextLong(); long next; int ans = 1; while (base >= 1) { long low = 0, high = base; while (hig...
JAVA
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> using namespace std; int main(){ int n,k,x=0,sum=0,a=1; cin>>n>>k; while(1){ if(sum>=n) break; sum+=a; if((sum-a)/a>=k){ sum-=a; ++a; --x; } ++x; } cout<<x<<endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; using ll = long long; using VI = vector<int>; using VL = vector<ll>; #define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++) #define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++) #define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--) #define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
// 2018/12/09 Tazoe #include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; int cnt = 0; while(N>0){ int x = (N-1)/(K+1)+1; N -= x; cnt++; } cout << cnt << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; int ans = 1, t = 1; while((t += (t+k-1)/k) <= n) ans++; cout << ans << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat>...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int ret = 1; int used = 1; while (true) { used += (used + k - 1) / k; if (used > n)break; ret++; } cout << ret << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat>...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
N, K = map(int, input().split()) ans = 1 s = 1 N -= 1 while 1: m = (s+K-1) // K if N < m: break s += m; N -= m ans += 1 print(ans)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
N, K = (int(x) for x in input().split()) t = 1 r = N - 1 s = 1 while True: b = s // K + 1 if s % K else s // K if r >= b: r -= b s += b t += 1 else: break print(t)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; int main() { int N, K; int cnt = 0; int num = 0; cin >> N >> K; for ( int i = 0; i < N; i++ ) { num++; if ( num * K >= N - i - 1 ) { num = 0; cnt++; } } cout << cnt << endl; return ( 0 ); }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
N,K = [int(i) for i in input().split()] weight = 1 ans = 1 N -= 1 while N > 0: d = 0 if weight % K == 0: d = weight // K else: d = weight // K + 1 N -= d weight += d if N >= 0: ans += 1 print(ans)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<iostream> #include<algorithm> #include<vector> #include<string> #define int long long using namespace std; signed main() { int n, k; cin >> n >> k; int sum = 0, ans = 0; while (sum < n) { int p = (sum + k - 1) / k; if (!sum)p = 1; if (sum + p > n)break; sum += p; ans++; } cout << ans << endl; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#define _USE_MATH_DEFINES #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <map> using namespace std; typedef pair<long long int, long long int> P; long long int INF = 1e18; long long int MOD = 1e9 + 7; int...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
//yukicoder@cpp14 //author:luckYrat(twitter:@luckYrat_) //<ここに一言> //せんげん! #include <iostream> #include <cmath> #include <algorithm> #include <iomanip> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <bitset> #include <cctype> #include <utility> #include <...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<iostream> #include<algorithm> #include<vector> using namespace std; typedef long long ll; #define mod 1000000007 int main(){ ll n,k; cin>>n>>k; ll ans=0,sum=0; while(1){ ll need=(sum+k-1)/k; if(need==0)need=1; if(n<need)break; n-=need; sum+=need; ans++; } cout<<an...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<cstdio> #include<functional> #include<algorithm> using namespace std; int main(void) { int n,k,x,sum,cnt; scanf("%d %d",&n,&k); cnt=1; sum=1; n--; while(1) { x=sum/k+(sum%k!=0); if(x>n) break; cnt++; n-=x; sum+=x; } printf("%d\n",cnt); return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
n,k = map(int,input().split()) ans = 0 d,s = 1,0 while True: # s/d <= k # s <= d*k while d*k < s: d += 1 if s+d > n: break s += d ans += 1 print(ans)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; int main() { int n, k, m = 0, i = 1, j = 0; cin >> n >> k; while (1) { while (j > k * i) i++; if (n - j < i) break; m++; j += i; } cout << m << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<iostream> #include<vector> #include<set> #include<algorithm> #include<queue> #include<utility> #define LL long long using namespace std; int main() { int n, _n, k; cin >> n >> k; int sum = 1, ans = 1; _n = n - 1; while ((sum + k - 1) / k <= _n) { _n -= (sum + k - 1) / k; sum += (sum + k - 1) / k; ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N,K; cin >> N >> K; ll ans = 1; ll sum = 1; N--; while(true){ if(N*K < sum) break; ll tmp = 0; if(sum%K == 0) tmp...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <bits/stdc++.h> using namespace std; int main() { int n, k, m=1, sum=0, ans=0; cin >> n >> k; while(n>=m){ ans++; sum += m; n -= m; m = (sum-1)/k+1; } cout << ans << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
n, k = map(int, input().split()) weight = 1 rest = n - 1 layers = 1 while True: add = weight // k + bool(weight % k) if add <= rest: rest -= add weight += add layers += 1 else: break print(layers)
PYTHON3
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <iostream> #include <complex> #include <string> #include <algorithm> #include <numeric> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <functi...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> #include <vector> using std::vector; using std::cin; using std::cout; using std::endl; int main() { int N, K, num = 0; // N: ブロック個数、K: ブロック強度、num: 積み上げるブロック数 vector<int> digit; cin >> N >> K; for (;;) { int n = 0; while (num > ++n * K); num += n; if (num > N) { break; } digit.p...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include<bits/stdc++.h> #define V vector #define VI vector<int> #define VVI vector<vector<int>> #define rep(i,n) for(int i=0;i<(n);i++) #define MOD 1000000007 using namespace std; int main(void){ int N,K; cin>>N>>K; int t=1,n=1,a=1; while(1){ n=(K+a-1)/K; a+=n; if(N<a){ ...
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; n--; int result = 1; int used = 1; int use; while (n >= 0) { result++; use = (used + k - 1) / k; used += use; n -= use; } cout << result - 1 << endl; return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include <iostream> using namespace std; long long N, K; int main() { cin >> N >> K; long long ret = 1, cnt = 1; while (true) { long long nex = (ret + K - 1) / K; if (ret + nex > N) { cout << cnt << endl; return 0; } ret += nex; cnt++; } return 0; }
CPP
p00389 Pilling Blocks
We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks without crushing. We have to build the tower abiding by the following ...
7
0
#include "bits/stdc++.h" #pragma warning(disable:4996) using namespace std; int main() { int N,K;cin>>N>>K; int ans=0; int sum=0; while (true) { int next=(sum-1)/K+1; if(ans==0)next=1; if (N < sum + next) { break; } else { sum+=next; ans++; } } cout<<ans<<endl; return 0; }
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include <iostream> #include <vector> using namespace std; int main(){ int n,k,t; bool f=true; vector<int> s; while(1){ cin >> n >> k; if(n==0&&k==0) break; for(int i=0;i<k;i++){ cin >> t; s.push_back(t); } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin >> t; s[j]-=t; } } fo...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include <iostream> #include <vector> #include <string> #include <cstring> #include <algorithm> #include <sstream> #include <map> #include <set> #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define INF 1<<30 #define pb push_back #define mp make_pair using namespace std; typedef long l...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
import java.io.*; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader r=new BufferedReader(new InputStreamReader(System.in)); while(true){ String s=r.readLine(); String[] t=s.split(" "); int[] n=new int[t.length]; for(int i=0;i<2;i++){ n[i]=Integer.pa...
JAVA
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include<stdio.h> int s[100]; int main(){ int n,k; int i,j; while(1){ scanf("%d %d",&n,&k); if(n==0)return 0; for(i=0;i<k;i++)scanf("%d",&s[i]); for(i=0;i<n;i++){ for(j=0;j<k;j++){ int x; scanf("%d",&x); s[j]-=x; } } for(i=0;i<k;i++)if(s[i]<0)break; if(i==k)printf("Yes\...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include<iostream> #include<sstream> #include<vector> #include<set> #include<map> #include<queue> #include<algorithm> #include<numeric> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #define rep(i,n) for(int i=0;i<n;i++) #define all(c) (c).begin(),(c).end() #define mp make_pair ...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, k; int s[]; int a[][]; boolean f; while (true) { n = sc.nextInt(); k = sc.nextInt(); if ((n | k) == 0) { break; } s = new int[k]; for (int i = 0; i < k...
JAVA
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include<iostream> #include<string> using namespace std; int main(){ while(true){ int N,K; string ans = "Yes"; cin >> N >> K; int S[K]; if( N == 0 && K == 0 ) break; for(int i = 0; i < K; ++i){ cin >> S[i]; } for(int i = 0; i < N; ++i){ for(int j = 0; j < K; ++j){ int B;...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include <iostream> using namespace std; int main() { int n, k; while (cin >> n >> k) { if (n == 0 && k == 0) { break; } int s[100]; bool hantei = true; for (int i = 0; i < k; i++) { cin >> s[i]; } int a; for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { cin >> a; s[j] -= ...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include<iostream> using namespace std; int main(){int n,k,l,i;while(1){cin>>n>>k;if(n==0&&k==0)break;int s[k];for(i=0;i<k;i++)s[i]=0,cin>>s[i];for(i=0;i<n;i++)for(int j=0;j<k;j++)cin>>l,s[j]-=l;for(i=0;i<k;i++){if(s[i]<0){cout<<"No\n";break;}if(i==k-1)cout<<"Yes\n";}}}
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include<bits/stdc++.h> using namespace std; int N, K; int M[110]; int main() { while(cin >> N >> K && N && K) { bool flag = false; for(int i = 0; i < K; i++)cin >> M[i]; for(int i = 0; i < N; i++) { for(int j = 0; j < K; j++) { int m; ...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; using ll=long long; const int MAX = (int)1e2; int N, K; void solve() { int s[MAX ]; bool ok=0; int b; //int b[MAX ][MAX]; for (int i = 0; i < K; i++) { cin >> s[i]; } for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) { ...
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
while True: N,K=map(int,raw_input().split()) if N==K==0:break S=map(int,raw_input().split()) L=[0]*K for i in range(N): temp=map(int,raw_input().split()) for j in range(K): L[j]+=temp[j] for i in range(K): if S[i]-L[i]<0: print "No" bre...
PYTHON
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook ...
7
0
#include<iostream> using namespace std; int main(){ int N,K,blood_sum[100],blood_num[100],blood; bool flag; while(1){ cin >>N>>K; if(N == 0 && K == 0)break; flag=0; for(int i=0 ; i < 100 ; i++)blood_sum[i]=0; for(int i=0 ; i < K ; i++)cin >>blood_num[i]; for(int i=0 ; i < N ; i++...
CPP