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
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; class Main{ static Scanner s; public static void main(String args[]){ // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); s = new Scanner(System.in); try{ while(true){ int n = s.nextInt(); int k = s.nextInt(); if(n + k == 0) return; System.out.println(solve(n, k)); } }catch(Exception e){ System.err.println(e); } } static String solve(int n, int k){ int supply_array[] = new int[k]; int demand_matrix[][] = new int[n][k]; for(int i = 0; i < k; i++){ supply_array[i] = s.nextInt(); } //print(supply_array); for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ demand_matrix[i][j] = s.nextInt(); } } //print(demand_matrix); for(int i = 0; i < k; i++){ int demand_sum = 0; for(int j = 0; j < n; j++){ demand_sum += demand_matrix[j][i]; } //System.out.println("demand: " + demand_sum + "\t supply: " + supply_array[i]); if(demand_sum > supply_array[i]) return "No"; } return "Yes"; } static void print(int a[]){ for(int i = 0; i < a.length; i++){ System.out.print(a[i] + "\t"); } System.out.println(); } static void print(int m[][]){ for(int i = 0; i < m.length; i++){ for(int j = 0; j < m[i].length; j++){ System.out.print(m[i][j] + "\t"); } System.out.println(); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
while True: n,k=map(int, raw_input().split()) if n==0 and k==0: break s = map(int, raw_input().split()) for i in xrange(n): b = map(int, raw_input().split()) for j in xrange(k): s[j] -= b[j] print "Yes" if len(filter(lambda x:x<0, s))==0 else "No"
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(){ int N,K; while(cin>>N>>K,N||K){ int s[K]; for(int i=0;i<K;i++){ cin>>s[i]; } int temp; bool flag=true; for(int j=0;j<N;j++){ for(int i=0;i<K;i++){ cin>>temp; s[i]-=temp; if(s[i]<0)flag=false; } } if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> using namespace std; int N, K, tmp; void solve() { vector<int> bloods(K), family(K); for (int i = 0; i < K; i += 1) cin>>bloods[i]; for (int i = 0; i < N; i += 1) { for (int j = 0; j < K; j += 1) { cin>>tmp; family[j]+=tmp; } } // calc for (int i = 0; i < K; i += 1) { if (family[i] > bloods[i]) { cout<<"No"<<endl; return; } } cout<<"Yes"<<endl; } int main(int argc, char const* argv[]) { while (true) { cin>>N>>K; if (N==0 && K==0) break; solve(); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int N,K,i,j,*S,B,a; while(a=1,cin>>N>>K,N||K){ S=new int[K]; for(i=K;i--;)cin>>S[i]; for(i=0;i<N;++i)for(j=K;j--;)cin>>B,S[j]-=B,S[j]<0?a=0:0; cout<<(a?"Yes":"No")<<endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <cstdio> using namespace std; #define loop(n) for(int lp=0; lp<(n); lp++) #define ascent(i, a, b) for(int (i)=(a); (i)<(b); (i)++) #define descent(i, a, b) for(int (i)=(a); (i)<(b); (i)--) #define cl clear() int main() { int n, k, s[100000], b[100][100]; bool flg; while(cin >> n >> k, n!=0&&k!=0) { ascent(i,0,100000) s[i]=0; ascent(i,0,100) ascent(j,0,100) b[i][j] = 0; flg = true; ascent(i,0,k) { cin >> s[i]; } ascent(i,0,n) { ascent(j, 0, k) { cin >> b[i][j]; } } ascent(j,0,k) { ascent(i,0,n) { s[j] -= b[i][j]; if(s[j] < 0) { flg = false; break; } } if(!flg)break; } if(flg) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <bits/stdc++.h> using namespace std; int main() { int N, K; while (cin >> N >> K, N) { vector<int> S(K); for (int i = 0; i < K; i++) { cin >> S[i]; } int B[N][K]; for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) { cin >> B[i][j]; } } bool poss = 1; for (int i = 0; i < K; i++) { int sum = 0; for (int j = 0; j < N; j++) { sum += B[j][i]; } if (sum > S[i]) { poss = 0; } } cout << (poss ? "Yes" : "No") << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner in=new Scanner(System.in); for(;;) { int ju=0; int N=in.nextInt(); int K=in.nextInt(); if((N|K)==0) return; int s[]=new int[K]; for(int i=0;i<K;i++) s[i]=in.nextInt(); for(int i=0;i<N;i++) for(int j=0;j<K;j++) { s[j]-=in.nextInt(); if(s[j]<0) ju=1; } if(ju==0) System.out.println("Yes"); else System.out.println("No"); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #include<cstring> int blood[101]; int main(){ int n, k; while (std::cin >> n >> k, n || k){ memset(blood, 0, sizeof(blood)); for (int i = 0; i < k; i++){ std::cin >> blood[i]; } for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ int a; std::cin >> a; blood[j] -= a; } } for (int i = 0; i < k; i++){ if (blood[i] < 0){ std::cout << "No" << std::endl; break; } if (i == k - 1)std::cout << "Yes" << std::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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #include<algorithm> using namespace std; int main() { int n, k; while (cin >> n >> k&&n != 0 && k != 0) { long long k1[100], k2[100]; bool l = true; int a; for (int i = 0; i < k; i++) { cin >> k1[i]; } fill(k2, k2 + k, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { cin >> a; if(l){ k2[j] += a; if (k2[j] > k1[j]) l = false; } } } if (l) cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#define _USE_MATH_DEFINES #define INF 100000000 #include <iostream> #include <sstream> #include <cmath> #include <cstdlib> #include <algorithm> #include <queue> #include <stack> #include <limits> #include <map> #include <string> #include <cstring> #include <set> #include <deque> #include <bitset> #include <list> using namespace std; typedef long long ll; typedef pair <int,int> P; static const double EPS = 1e-8; int main(){ int N,K; int tank[100]; while(~scanf("%d %d",&N,&K)){ if(N==K && K==0) break; for(int i=0;i<K;i++){ scanf("%d",tank+i); } bool isok = true; for(int i=0;i<N;i++){ for(int j=0;j<K;j++){ int B; scanf("%d",&B); tank[j]-=B; if(tank[j]<0) isok = false; } } printf("%s\n",isok ? "Yes" : "No"); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.awt.geom.Point2D; import java.io.*; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.NoSuchElementException; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Stack; import java.util.TreeMap; public class Main { static PrintWriter out = new PrintWriter(System.out); static FastScanner sc = new FastScanner(); static Scanner stdIn = new Scanner(System.in); static TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>(); public static void main(String[] args) { while(true) { int n = sc.nextInt(); int k = sc.nextInt(); if(n == 0 && k == 0) break; int[] list = new int[k]; for(int i = 0; i < k; i++) { list[i] = sc.nextInt(); } boolean OK = true; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { list[j] -= sc.nextInt(); if(list[j] < 0) { OK = false; } } } out.println((OK)?"Yes":"No"); } out.flush(); } } //------------------------------// //-----------// class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public double nextDouble() { return Double.parseDouble(next()); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<cstdio> #include<vector> using namespace std; int main(){ int N, K; while( scanf("%d %d", &N, &K), N||K ){ vector<int> bloods; for( int i=0; i<K; i++ ){ int b; scanf("%d", &b); bloods.push_back(b); } for( int i=0; i<N; i++ ){ for( int j=0; j<K; j++ ){ int b; scanf("%d", &b ); bloods[j] -= b; } } bool runout = false; for( int i=0; i<K; i++ ){ if( bloods[i] < 0 ){ runout = true; break; } } printf(runout?"No\n":"Yes\n"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner s = new Scanner(System.in); while(s.hasNext()){ int vampireNum = s.nextInt(); int bloodType = s.nextInt(); if(vampireNum == 0 && bloodType == 0){ break; } int[] stock = new int[bloodType]; for(int i = 0; i < stock.length; i++){ stock[i] = s.nextInt(); } for(int i = 0; i < vampireNum; i++){ for(int j = 0; j < bloodType; j++){ stock[j] -= s.nextInt(); } } boolean result = true; for(int i = 0; i < bloodType; i++){ if(stock[i] < 0)result = false; } System.out.println(result?"Yes":"No"); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> int main(){ int N,K,i,j,S[100],B,a; while(a=1,scanf("%d %d",&N,&K),N||K){ for(i=K;i--;)scanf("%d",S+i); for(i=N;i--;)for(j=K;j--;)scanf("%d",&B),S[j]-=B,S[j]<0?a=0:0; puts(a?"Yes":"No"); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> int main(){ int N,K; int S[100]; int B; int count; int h=1; int i,j; scanf("%d %d",&N,&K); while((N!=0)&&(K!=0)){ h=1; for(i=0;i<K;i++){ scanf("%d",&S[i]); } for(i=0;i<N;i++){ for(j=0;j<K;j++){ scanf("%d",&B); S[j]=S[j]-B; if(S[j]<0){ h=0; } } } if(h==1){ printf("Yes\n"); }else{ printf("No\n"); } scanf("%d %d",&N,&K); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
while True: n, k = map(int, input().split()) if n == 0: break s_list = list(map(int, input().split())) for _ in range(n): b_list = list(map(int, input().split())) for i in range(k): s_list[i] -= b_list[i] for s in s_list: if s < 0: print("No") break else: print("Yes")
PYTHON3
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<cstdio> int s[110],n,m; int main() { int i,j,k,l; bool pass; while (1) { scanf("%d%d",&n,&m); if (n==0&&m==0) break; for (i=0;i<m;i++) scanf("%d",&s[i]); for (i=0;i<n;i++) for (j=0;j<m;j++) { scanf("%d",&k); s[j]-=k; } pass=true; for (i=0;i<m;i++) if (s[i]<0) { pass=false; break; } if (pass) printf("Yes\n"); else printf("No\n"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main() { int N,K,s[100],b,i,j; bool f; while(cin>>N>>K,N|K){ for(i=0;i<K;i++)cin>>s[i]; for(j=0;j<N;j++)for(i=0;i<K;i++){cin>>b;s[i]-=b;} f=1; for(i=0;i<K;i++)if(s[i]<0)f=0; if(f) cout<<"Yes"<<endl; else cout<<"No"<<endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <stdio.h> #include <string.h> int main() { int n, k; int source[128]; while (scanf("%d%d", &n, &k), n){ memset(source, 0, sizeof(source)); for (int i = 0; i < k; i++){ scanf("%d", source + i); } for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ int tmp; scanf("%d", &tmp); source[j] -= tmp; } } for (n = 0; source[n] >= 0 && n < k; n++); puts(n == k ? "Yes" : "No"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <bits/stdc++.h> using namespace std; int main(){ while(true){ int n,k; cin>>n>>k; if(n==0) return 0; vector<int> s(k); 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; cin>>b; s[j]-=b; } } for(int i=0;i<k;i++){ if(s[i]<0){ cout<<"No"<<endl; goto next; } } cout<<"Yes"<<endl; next:; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { private static BufferedReader br = null; public static void main(String[] args) { br = new BufferedReader(new InputStreamReader(System.in)); while(true) { try { String line = null; String[] lines = null; line = br.readLine(); lines = line.split(" "); int N = Integer.parseInt(lines[0]); int K = Integer.parseInt(lines[1]); if (N == 0 && K == 0) { return; } line = br.readLine(); lines = line.split(" "); int[] bloodAmt = new int[K]; for (int i = 0; i < K; i ++) { bloodAmt[i] = Integer.parseInt(lines[i]); } for (int i = 0; i < N; i ++) { line = br.readLine(); lines = line.split(" "); for (int j = 0; j < K; j ++) { bloodAmt[j] -= Integer.parseInt(lines[j]); } } for (int i = 0; i < K; i ++) { if (bloodAmt[i] < 0) { System.out.println("No"); break; } if (i == K-1) { System.out.println("Yes"); } } } catch(Exception e) { e.printStackTrace(); } } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.*; import java.util.*; import java.math.*; public class Main{ public static void main(String[] arg) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String[] ia; while(true){ ia = in.readLine().split(" "); int N = Integer.parseInt(ia[0]); int K = Integer.parseInt(ia[1]); if(N == 0 && K == 0){ break; } int[] S = new int[K]; ia = in.readLine().split(" "); for(int i = 0;i < K; ++i){ S[i] = Integer.parseInt(ia[i]); } for(int i = 0;i < N; ++i){ ia = in.readLine().split(" "); for(int j = 0;j < K; ++j){ S[j] -= Integer.parseInt(ia[j]); } } boolean yet = true; for(int i = 0;i < K; ++i){ if(S[i] < 0){ yet = false; break; } } if(yet){ System.out.println("Yes"); } else { System.out.println("No"); } } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <stdio.h> int main(void) { int want[100]; int blood[100]; int n, k; while (1){ scanf("%d%d", &n, &k); if (n == 0 && k == 0) break; for (int i = 0; i < k; i++){ scanf("%d", &blood[i]); } for (int i = 0; i < k; i++){ want[i] = 0; } for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ int m; scanf("%d", &m); want[j] += m; } } int i; for (i = 0; i < k; i++){ if (want[i] > blood[i]){ break; } } printf("%s\n", i == k ? "Yes" : "No"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int N,K,i,j,*S,B,a; while(a=1,cin>>N>>K,N||K){ S=new int[K]; for(i=K;i--;)cin>>S[i]; for(i=N;i--;)for(j=K;j--;)cin>>B,S[j]-=B,S[j]<0?a=0:0; cout<<(a?"Yes":"No")<<endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> using namespace std; int main(){ int n,k; while(cin>>n>>k,n,k){ vector<int> amount; for(int i=0,s;i<k;++i){ cin>>s; amount.push_back(s); } bool f = true; for(int i=0;i<n;++i){ for(int j=0,b;j<k;++j){ cin>>b; amount[j]-=b; if(amount[j]<0) f=false; } } cout<<((f)?"Yes\n":"No\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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; #define loop(i,a,b) for(int i=(a); i<int(b); i++) #define rep(i,b) loop(i,0,b) int main(){ int n, k; while(cin >> n >> k , n|k){ int t[110]; bool possible = true; rep(i, 110)t[i] = 0; rep(i, k)cin >> t[i]; rep(i, n){ rep(j, k){ int input; cin >> input; t[j]-= input; } } rep(i, k) if(t[i] < 0) possible = false; if(possible) cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n, k, b, f; int s[110], sum[110]; while(cin>>n>>k,n){ for(int i=0;i<k;i++){ cin>>s[i]; sum[i]=0; } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin>>b; sum[j]+=b; } } f=0; for(int i=0;i<k;i++){ if(sum[i]>s[i]){ f=1; break; } } if(f) cout<<"No"<<endl; else cout<<"Yes"<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <bits/stdc++.h> using namespace std; int main() { int n, k; while (scanf("%d %d", &n, &k) && n){ int S[128]; for (int i = 0; i < k; i++){ scanf("%d", S + i); } bool flag = true; for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ int x; scanf("%d", &x); S[j] -= x; if (S[j] < 0) flag = false; } } if (flag) printf("Yes\n"); else printf("No\n"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> int main(){ int N,K; while(1){ scanf("%d%d",&N,&K);if(N==0&&K==0)break; int n[101][101]={}; int s[101]={}; for(int i=0;i<K;i++) scanf("%d",&s[i]); for(int i=0;i<N;i++) for(int j=0;j<K;j++) scanf("%d",&n[i][j]); bool f=true; for(int i=0;i<K;i++){ int S=0; for(int j=0;j<N;j++) S+=n[j][i]; if(S>s[i])f=false; } if(f==false)printf("No\n"); else printf("Yes\n"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> #include <algorithm> #define ascent(i, a, b) for(int (i) = (a); (i) < (b); (i) ++) using namespace std; int main() { int n, k; vector<int> s; int b[100]; while(true) { cin >> n >> k; if(!n && !k) break; int tmp; s.clear(); ascent(i, 0, k) { cin >> tmp; s.push_back(tmp); } ascent(i, 0, 100) { b[i] = 0; } ascent(i, 0, n) { ascent(j, 0, k) { cin >> tmp; b[j] += tmp; } } bool flg = true; ascent(i, 0, k) { if(s[i] < b[i]) { flg = false; break; } } if(flg) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(void) { int N,K; while(cin >> N >> K, N | K){ int blood[100000] = {}; bool f = true; for(int i = 0; i < K; i++) cin >> blood[i]; int drain; for(int i = 0; i < N; i++){ for(int j = 0; j < K; j++){ cin >> drain; blood[j] -= drain; if(blood[j] < 0) f = false; } } if(f) cout << "Yes\n"; else cout << "No\n"; } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(void){ int N, K; //家族の人数と血液型の種類数 int S[200]; //冷蔵庫にある血液型の血液量 int B[200][200]; //吸血鬼が使う血液型の血液量 while(true){ cin >> N >> K; if(N + K == 0) break; for(int i = 1; i <= K; i++){ cin >> S[i]; } for(int i = 1; i <= N; i++){ for(int j = 1; j <= K; j++){ cin >> B[i][j]; } } int cnt = 0; for(int i = 1; i <= K; i++){ int sum = 0; for(int j = 1; j <= N; j++){ sum += B[j][i]; } if(sum <= S[i]) cnt++; } if(cnt == K) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n,k; int s[100],b[100][100]; bool f; while(1){ cin >> n >> k; if(!n && !k)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++)cin >> b[i][j]; } f = true; for(int i=0;i<k;i++){ for(int j=0;j<n;j++){ s[i] -= b[j][i]; if(s[i] < 0){ f = false; break; } } if(!f)break; } if(f)cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
while 1: N,K = map(int,raw_input().split()) if N == 0: break S = map(int,raw_input().split()) B = [map(int,raw_input().split()) for i in range(N)] for breed in B: for i in range(K): S[i] -= breed[i] print "Yes" if min(S) >= 0 else "No"
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n,k; while(cin >> n >> k, n+k) { int s[k]; for(int i=0; i<k; i++) cin >> s[i]; int f=0; for(int i=0; i<n; i++) { for(int j=0; j<k; j++) { int x; cin >> x; s[j] -= x; if (s[j] < 0) f = 1; } } if (f) cout << "No" << endl; else cout << "Yes" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #include<string> #include<vector> #include<utility> #include<queue> #include<algorithm> #include<cmath> #define INF 2147483647 #define llINF 9223372036854775807 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; int main(){ int a,b; while(cin>>a>>b,a+b){ int S[b]; for(int i=0;i<b;i++) cin>>S[i]; int flag=1; for(int i=0;i<a;i++){ for(int j=0;j<b;j++){ int B; cin>>B; S[j]-=B; if(S[j]<0){ flag=0; } } } if(flag) cout<<"Yes"<<endl; else cout<<"No"<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.PrintWriter; import java.io.StringWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); StringWriter result = new StringWriter(); PrintWriter out = new PrintWriter(result); while(true){ int members = sc.nextInt(); int kinds = sc.nextInt(); if(members == 0 && kinds == 0){ break; } int[] keeps = new int[kinds]; boolean flag = true; for(int i = 0;i < kinds;i++){ keeps[i] = sc.nextInt(); } for(int i = members;i > 0;i--){ for(int j = 0;j < kinds;j++){ keeps[j]-=sc.nextInt(); } } for(int i : keeps){ if(i < 0){ flag = false; } } out.println(flag?"Yes":"No"); } System.out.print(result.toString()); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) using namespace std; int main(){ int n,m; while(cin>>n>>m,n){ int a[m],b[m],x,f=0; memset(b,0,sizeof(b)); r(i,m)cin>>a[i]; r(i,n)r(j,m){ cin>>x; b[j]+=x; } r(i,m)if(a[i]<b[i]){ cout<<"No"<<endl; f++; break; } if(!f)cout<<"Yes"<<endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <sstream> #include <string> #include <vector> #include <map> #include <algorithm> #include <iostream> #include <utility> #include <set> #include <cctype> #include <queue> #include <stack> #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> using namespace std; #define INF 100000000 #define MAXK 110 typedef long long ll; int N, K; int S[MAXK]; int main(void) { while (1) { cin >> N >> 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; cin >> b; S[j] -= b; } } int i; for (i = 0; i < K; i++) { if (S[i] < 0) break; } if (i == K) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <string> #include <map> #include <queue> #include <stack> #include <algorithm> #define rep(i, j) FOR(i, 0, j) #define FOR(i, j, k) for(int i = j; i < k; ++i) using namespace std; int main(){ int n, k, in; while(scanf("%d%d", &n, &k) && (n || k)){ vector<int>s; vector<int>b(100); rep(i, k) scanf("%d", &in), s.push_back(in); rep(i, n) rep(j, k){ scanf("%d", &in); b[j] += in; } bool flag = false; rep(i, k) if(s[i] < b[i]) flag = true; if(flag) puts("No"); else puts("Yes"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(void){ int n,k; while(cin >> n >> k){ if((n|k) == 0) break; int s[k]; int b[n][k]; for(int i=0;i<k;i++) cin >> s[i]; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin >> b[i][j]; } } bool isok = true; for(int i=0;i<k;i++){ int tmp=0; for(int j=0;j<n;j++){ tmp += b[j][i]; } if(tmp > s[i]){ isok = false; } } isok?cout << "Yes" << endl:cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { Scanner sc; void run(){ sc = new Scanner( System.in ); while( true ){ boolean possible = true; int n = sc.nextInt(); int k = sc.nextInt(); if( n == 0 && k == 0 ){ return; } int[] s = new int[ k ]; int[] rs = new int[ k ]; for( int i = 0; i < k; i++ ){ s[ i ] = sc.nextInt(); rs[ i ] = 0; } for( int i = 0; i < n; i++ ){ for( int j = 0; j < k; j++ ){ rs[ j ] += ( sc.nextInt() ); if( rs[ j ] > s[ j ] ){ possible = false; } } } System.out.println( possible ? "Yes" : "No" ); } } public static void main( String[] args ){ new Main().run(); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <cstdio> int n,k; int s[100]; int main(){ while(scanf("%d%d", &n, &k)){ if(n == 0 && k == 0) break; for(int i = 0; i < k; i++) scanf("%d", &s[i]); for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ int b; scanf("%d", &b); s[j] -= b; } } bool ok = true; for(int i = 0; i < k; i++) if(s[i] < 0) ok = false; if(ok) printf("Yes\n"); else printf("No\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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #include<vector> using namespace std; int main(){ int x,K,N; int pre[200],rea[200]; while(cin>>N>>K,K||N){ for(int i=0;i<K;i++){ rea[i]=0; cin>>x; pre[i]=x; } for(int i=0;i<N;i++) for(int j=0;j<K;j++){ cin>>x; rea[j]+=x; } int i; for(i=0;i<K;i++){ if(rea[i]>pre[i]){ cout<<"No"<<endl; break; } } if(i==K) cout<<"Yes"<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(void){ int N,K,S[100000],B[1000][1000]; int sum; int cnt; while(1){ cnt = 0; cin >> N >> K; if( N == 0 && K == 0 ) break; for( int i = 0 ; i < K ; i++ ){ cin >> S[i]; } for( int j = 0 ; j < N ; j++ ){ for( int i = 0 ; i < K ; i++ ){ cin >> B[j][i]; } } for( int i = 0 ; i < K ; i++ ){ sum = 0; for( int j = 0 ; j < N ; j++ ){ sum += B[j][i]; } if( sum <= S[i] ) cnt++; } if( cnt == K ) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> int main(){ int N,K,blood[101],family[101],tmp,i,j,x; while(1){ scanf("%d %d", &N, &K); if(N==0&&K==0) break; tmp=1; for(i=0;i<K;i++) scanf("%d",&blood[i]); for(i=0;i<N;i++){ for(j=0;j<K;j++){ scanf("%d",&x); blood[j]-=x; if(blood[j]<0) tmp=0; } } if(tmp==0) printf("No\n"); else printf("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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); int k = sc.nextInt(); if ((n | k) == 0) break; int[] s = new int[k]; for (int i = 0; i < k; i++) s[i] = sc.nextInt(); for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { s[j] -= sc.nextInt(); } } boolean flag = true; for (int i = 0; i < k; i++) { if (s[i] < 0) { flag = false; break; } } System.out.println(flag ? "Yes" : "No"); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n,k; int s[100],b[100][100]; bool f; while(1){ cin >> n >> k; if(!n && !k)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++)cin >> b[i][j]; } f = true; for(int i=0;i<k;i++){ for(int j=0;j<n;j++){ s[i] -= b[j][i]; if(s[i] < 0){ f = false; break; } } } if(f)cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main() { int N,K; while (cin >> N >> K, N!=0||K!=0) { int str[K]; for (int i=0; i<K; i++) { cin >> str[i]; } bool f = true; for (int i=0; i<N; i++) { for (int j=0; j<K; j++) { int tmp; cin >> tmp; str[j] -= tmp; if (str[j] < 0) f=false; } } cout << ((f) ? "Yes" : "No") << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #include<vector> using namespace std; int main(){ int i, j, n, k, _s, b, check; vector<int> s; while(1){ cin >> n >> k; if(n == 0 && k == 0) break; for(i=0; i<k; ++i){ cin >> _s; s.push_back(_s); } check = 0; for(i=0; i<n; ++i){ for(j=0; j<k; ++j){ cin >> b; if(check == 0){ s[j] -= b; if(s[j] < 0) check = 1; } } } if(check == 0) cout << "Yes" << endl; else cout << "No" << endl; s.clear(); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main(){ int n,k,s[101],b[101][101],want[101]; while(cin>>n>>k){ if(n==0&&k==0)break; int flg=1; rep(i,101)want[i]=0; rep(i,k){ cin>>s[i]; } rep(i,n)rep(j,k){ cin>>b[i][j]; want[j]+=b[i][j];//point } rep(i,k){ if((s[i]-want[i])<0)flg=0; } if(!flg)cout<<"No"<<endl; else cout<<"Yes"<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int n, k; int[] stock; int[] needs; StringTokenizer st; StringBuilder sb = new StringBuilder(); next: while ((line = br.readLine()) != null && !line.isEmpty()) { n = Integer.parseInt(line.substring(0, line.indexOf(' '))); k = Integer.parseInt(line.substring(line.indexOf(' ') + 1)); if (n == 0 && k == 0) { break; } stock = new int[k]; needs = new int[k]; st = new StringTokenizer(br.readLine()); for (int i = 0; i < k; i++) { stock[i] = Integer.parseInt(st.nextToken()); } for (int i = 0; i < n; i++) { st = new StringTokenizer(br.readLine()); for (int j = 0; j < k; j++) { needs[j] += Integer.parseInt(st.nextToken()); } } for (int i = 0; i < k; i++) { if (stock[i] < needs[i]) { sb.append("No" + '\n'); continue next; } } sb.append("Yes" + '\n'); } System.out.print(sb.toString()); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(void){ int N,K; int a; int s[100]; int ds[100]; while(cin>>N>>K,N||K){ for(int i=0;i<K;i++)cin>>s[i]; for(int i=0;i<K;i++)ds[i]=0; for(int i=0;i<N;i++){ for(int j=0;j<K;j++){ cin>>a; ds[j]+=a; } } for(int i=0;i<K;i++){ if(ds[i]>s[i]){ cout<<"No"<<endl; goto ST; } } cout<<"Yes"<<endl; ST:; } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <cstdio> using namespace std; int main() { int N, K; int S[200]; while (scanf("%d %d", &N, &K), N + K){ for (int i = 0; i < K; i++){ scanf("%d", &S[i]); } bool f = true; for (int i = 0; i < N; i++){ for (int j = 0; j < K; j++){ int B; scanf("%d", &B); S[j] -= B; if (S[j] < 0){ f = false; } } } printf(f ? "Yes\n" : "No\n"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> using namespace std; int main(){ int n,k,b,s[101],i; for(;scanf("%d%d",&n,&k),n|k;){ for(i=0;i<k;i++) scanf("%d",s+i); for(i=0;i<n*k;s[i++%k]-=b) scanf("%d",&b); for(i=0;i<k;) s[i++]<0? n=0:0; puts(n?"Yes":"No"); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main() { int n, k, b; int stock[100]; bool judge; while(cin >> n >> k, (n||k)) { if(!(n||k))goto YAMADA; judge = 0; for( int i = 0; i < k; i++) { cin >> stock[i]; } for( int i = 0; i < n; i++) for( int j = 0; j < k; j++) { cin >> b; stock[j] -= b; if(stock[j] < 0) judge = 1; } if(judge == 1) cout << "No" << endl; else cout << "Yes" << endl; } YAMADA: 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n,k,tmp; int s[100],b[100]; bool f; while(1){ cin >> n >> k; if(!n && !k)break; for(int i=0;i<k;i++){ cin >> s[i]; b[i] = 0; } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin >> tmp; b[j] +=tmp; } } f = true; for(int i=0;i<k;i++){ if(b[i] > s[i]){ f = false; break; } } if(f)cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <cstdio> #include <vector> using namespace std; int main() { int N, K; while(1) { scanf("%d%d", &N, &K); if(N == 0) break; vector<int> S(K); for(int i=0; i<K; i++) scanf("%d", &S[i]); vector<int> sum(K); for(int i=0; i<N; i++) { for(int j=0; j<K; j++) { int val; scanf("%d", &val); sum[j] += val; } } bool ok = true; for(int i=0; i<K; i++) { if(sum[i] > S[i]) ok = false; } printf("%s\n", ok ? "Yes" : "No"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
# AOJ 1019: Vampirish Night # Python3 2018.7.4 bal4u while True: n, k = map(int, input().split()) if n == 0: break s = list(map(int, input().split())) b = [0]*k for i in range(n): a = list(map(int, input().split())) for j in range(k): b[j] += a[j] ans = True for i in range(k): if b[i] > s[i]: ans = False break print("Yes" if ans else "No")
PYTHON3
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; const int KMAX = 100; int blood[KMAX]; int main(){ int N, K; while(cin >> N >> K){ if(N == 0 && K == 0) break; for(int i = 0; i < K; i++){ cin >> blood[i]; } for(int i = 0; i < N; i++){ for(int j = 0; j < K; j++){ int needs; cin >> needs; blood[j] -= needs; } } bool f = false; for(int i = 0; i < K; i++){ if(blood[i] < 0){ f = true; break; } } if(f) cout << "No" << endl; else cout << "Yes" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <cstring> using namespace std; int main(){ int N, K; int S[100]; while(cin >> N >> K, N){ 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 t; cin >> t; S[j] -= t; } } bool ok = true; for(int i=0;i<K;i++) if(S[i] < 0) ok = false; cout << (ok ? "Yes" : "No") << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<cstdio> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ for(int n,k;scanf("%d%d",&n,&k),n||k;){ int blood[100]; rep(i,k) scanf("%d",blood+i); rep(i,n)rep(j,k){ int b; scanf("%d",&b); blood[j]-=b; } bool ok=true; rep(i,k)if(blood[i]<0){ ok=false; break; } puts(ok?"Yes":"No"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> using namespace std; int main(){ int n, k, s, b; while( cin >> n >> k , n || k ){ vector<int> S; for(int i=0 ; i<k ; i++ ){ cin >> s; S.push_back(s); } for(int i=0 ; i<n ; i++ ){ for(int j=0 ; j<k ; j++ ){ cin >> b; S[j] -= b; } } bool flag = true; for(int i=0 ; i<k ; i++ ){ if( S[i] < 0 ){ flag = false; } } cout << ( (flag)? "Yes" : "No" ) << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main(){ int N, K; int S[101]; int B; while(cin >> N >> K){ if(N == 0 && K == 0) break; bool flag = 1; for(int i = 0 ; i < K ; i++){ cin >> S[i]; } for(int i = 0 ; i < N ; i++){ for(int j = 0 ; j < K ; j++){ cin >> B; S[j] -= B; if(S[j] < 0) flag = 0; } } if(flag) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <string> using namespace std; int main(void){ int n,k; while(cin >> n >> k,n|k){ bool ok=true; int r[100],tmp; for(int i=0;i<k;i++) cin >> r[i]; for(int j=0;j<n;j++){ for(int i=0;i<k;i++){ cin >> tmp; r[i]-=tmp; if(r[i]<0) ok=false; } } if(ok) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <stdio.h> #include <cmath> #include <algorithm> #include <stack> using namespace std; void func(int N,int K){ int exist[101] = {0},need[101] = {0},tmp; for(int i = 1; i <= K; i++){ scanf("%d",&exist[i]); } for(int i = 1; i <= N; i++){ for(int p = 1; p <= K; p++){ scanf("%d",&tmp); need[p] += tmp; } } bool FLG = true; for(int i = 1; i <= K; i++){ if(exist[i] < need[i]){ FLG = false; break; } } if(FLG)printf("Yes\n"); else{ printf("No\n"); } } int main(){ int N,K; while(true){ scanf("%d %d",&N,&K); if(N == 0 && K == 0)break; func(N,K); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); while ((n > 0) && (k > 0)){ int[] s = new int[k]; for (int i = 0; i < k; i++){ s[i] = sc.nextInt(); } int[][] b = new int[n][k]; for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ b[i][j] = sc.nextInt(); } } int i = 0, j, flag = 1; while (i < n){ j = 0; while (j < k){ s[j] -= b[i][j]; if (s[j] < 0){ System.out.println("No"); flag = 0; i = n; j = k; } j++; } i++; } if (flag > 0){ System.out.println("Yes"); } n = sc.nextInt(); k = sc.nextInt(); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> int main(){ int N,K,op; while(std::cin >> N >> K && N && K){ int S[K],B[K]; for(int i=0;i<K;i++){ std::cin >> S[i]; B[i] = 0; } for(int j=0;j<N;j++){ for(int i=0;i<K;i++){ std::cin >> op; B[i] += op; } } bool iscan = true; for(int i=0;i<K;i++){ if(B[i] > S[i]){ iscan = false; break; } } iscan?std::cout << "Yes" << std::endl:std::cout << "No" << std::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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n,k; while(cin >> n >> k && n+k){ int blood[k]; int flg = 0; for(int i = 0; i < k; i++) cin >> blood[i]; for(int i = 0; i < n; i++){ int data; for(int j = 0; j < k; j++){ cin >> data; blood[j]-=data; if(blood[j] < 0) flg = 1; } } if(!flg) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main() { int N, K; while(cin >> N >> K && (N|K)) { int S[100]; for(int i=0; i<K; i++) { cin >> S[i]; } int B[100][100]; for(int i=0; i<N; i++) { for(int j=0; j<K; j++) { cin >> B[i][j]; } } for(int i=0; i<K; i++) { int sum = 0; for(int j=0; j<N; j++) { sum += B[j][i]; } if(S[i] < sum) { cout << "No" << endl; goto EXIT; } } cout << "Yes" << endl; EXIT:; } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> using namespace std; int main(){ int n,k,b,s[101],i,j; for(;scanf("%d%d",&n,&k),n|k;){ for(i=0;i<k;i++) scanf("%d",s+i); for(i=0;i<n;i++){ for(j=0;j<k;j++){ scanf("%d",&b); s[j]-=b; } } b=1; for(i=0;i<k;) if(s[i++]<0) b=0; puts(b?"Yes":"No"); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.*; class Main { static void solve (int n, int k, int[] needs, int[][] wants) { for (int i = 0; i < k; i++) { int sum = 0; for (int j = 0; j < n; j++) { sum += wants[j][i]; } if (sum > needs[i]) { System.out.println("No"); return; } } System.out.println("Yes"); } public static void main (String [] args) { Scanner sc = new Scanner(System.in); while(true) { int n = sc.nextInt(); int k = sc.nextInt(); if (n == 0 && k == 0) break; int [] needs = new int[k]; for(int i = 0; i < k; i++) needs[i] = sc.nextInt(); int [][] wants = new int[n][k]; for(int i = 0; i < n; i++) { for (int j = 0; j < k; j++) wants[i][j] = sc.nextInt(); } solve(n, k, needs, wants); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #include<sstream> #include<fstream> #include<cstdio> #include<vector> #include<list> #include<stack> #include<queue> #include<deque> #include<map> #include<set> #include<algorithm> #include<cstdlib> #include<cmath> #include<string> using namespace std; int main(){ int n,k; while(scanf("%d %d",&n,&k),n||k){ vector<int> blood; for(int x=0;x<k;++x){ int j;scanf("%d",&j);blood.push_back(j); } for(int x=0;x<n;++x){ for(int y=0;y<k;++y){ int w;scanf("%d",&w); blood[y] -= w; } } bool ok = true; for(int x=0;x<k;++x){ if(blood[x]<0)ok = false; } if(ok){ printf("Yes\n"); }else{ printf("No\n"); } } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> using namespace std; int main(){ int n,k,matrix[105][105]; while(1){ bool out = true; cin >> n >> k; if(!(n|k)) break; for(int i=0;i <= n;i++){ for(int j=0;j < k;j++){ cin >> matrix[i][j]; } } for(int i=0;i < k;i++){ int sum = 0; for(int j=1;j <= n;j++){ sum += matrix[j][i]; } if(sum > matrix[0][i]){ out = false;break; } } if(out) cout << "Yes" << endl; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <string.h> using namespace std; int exist[100000]; int needed[100000]; int main(){ int n,k; while(1) { cin >> n >> k; if (n==0)break; memset(exist,0,sizeof(exist)); memset(needed,0,sizeof(needed)); for (int i=0; i<k; i++) { cin >> exist[i]; } int tmp; for (int i=0; i<n; i++) { for (int j=0; j<k; j++) { cin >> tmp; needed[j]+=tmp; } } int ok=1; for (int i=0; i<k; i++) { if (exist[i]<needed[i]) { ok=0; break; } } (ok==1)?cout << "Yes" << endl:cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n, k, b, f; int sum[110], s[110]; while(1){ cin>>n>>k; if(n==0&&k==0) break; for(int i=0;i<k;i++){ cin>>s[i]; sum[i]=0; } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin>>b; sum[j]+=b; } } f=0; for(int i=0;i<k;i++){ if(sum[i]>s[i]){ f=1; break; } } if(f) cout<<"No"<<endl; else cout<<"Yes"<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); int k = sc.nextInt(); if (n == 0 && k == 0) break; int s[] = new int[k]; for (int i = 0; i < k; i++) { s[i] = sc.nextInt(); } boolean result = true; for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { s[j] -= sc.nextInt(); if (s[j] < 0) { result = false; } } } if (result) { System.out.println("Yes"); } else { System.out.println("No"); } } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <cstdio> #include <iostream> using namespace std; int main(){ while(1){ int n, k; long s[100]; scanf(" %d %d", &n, &k); if(n==0 && k==0) break; for(int i=0; i<k; ++i) scanf(" %ld", &s[i]); for(int i=0; i<n; ++i){ for(int j=0; j<k; ++j){ int b; scanf(" %d", &b); s[j]-=b; } } bool ans=true; for(int i=0; i<k; ++i){ if(s[i]<0) ans=false; } if(ans) printf("Yes\n"); else printf("No\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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] s; while (n != 0 && k != 0) { s = new int[k]; for (int i = 0; i < k; i++) { s[i] = in.nextInt(); } boolean isYes = true; for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { s[j] -= in.nextInt(); if (isYes) { isYes = s[j] >= 0; } } } System.out.println(isYes ? "Yes" : "No"); n = in.nextInt(); k = in.nextInt(); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; import static java.math.BigInteger.*; import static java.lang.Character.*; class AOJ1019 { public void run() { Scanner sc = new Scanner(System.in); while (true) { int N = sc.nextInt(); int K = sc.nextInt(); if (N == 0 && K == 0) return; int[] S = new int[K]; for (int i = 0; i < K; i++) S[i] = sc.nextInt(); int[][] B = new int[N][K]; for (int i = 0; i < N; i++) for (int j = 0; j < K; j++) B[i][j] = sc.nextInt(); boolean f = true; int[] T = new int[K]; for (int i = 0; i < K; i++) { for (int j = 0; j < N; j++) T[i] += B[j][i]; if(T[i] > S[i]) { f = false; break; } } System.out.println(f ? "Yes" : "No"); } } } public class Main { public static void main(String... args) { new AOJ1019().run(); } public static void debug(Object... os) { System.err.println(java.util.Arrays.deepToString(os)); } } class Scanner { final java.util.Scanner sc; public double nextDouble() { return Double.parseDouble(sc.next()); } public Scanner(java.io.InputStream is) { this.sc = new java.util.Scanner(is); } public boolean hasNext() { return sc.hasNext(); } public String next() { return sc.next(); } public int nextInt() { return Integer.parseInt(sc.next()); } public String nextLine() { return sc.nextLine(); } public long nextLong() { return Long.parseLong(sc.next()); } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
def judge(stock, require): for i in range(0, len(stock)): if stock[i] < require[i]: return 'No' return 'Yes' while True: inpt = map(int, raw_input().split()) if inpt[0] == 0: break else: n = inpt[0] k = inpt[1] stock = map(int, raw_input().split()) require = [] for i in range(0, k): require.append(0) for i in range(0, n): blood = map(int, raw_input().split()) for j in range(0, k): require[j] += blood[j] print judge(stock, require)
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<cstdio> #define MAX 100 int main(int argc, char const *argv[]) { int N, K; int S[MAX], sum[MAX]; int temp; while(1){ bool flag = true; scanf("%d %d", &N, &K); if(N==0 && K==0) break; for(int i=0; i<K; i++){ sum[i] = 0; scanf("%d", &S[i]); } for(int i=0; i<N; i++){ for(int j=0; j<K; j++){ scanf("%d", &temp); sum[j] += temp; } } for(int i=0; i<K; i++){ if(S[i] < sum[i]) { flag = false; break;} } if(flag) printf("Yes\n"); else printf("No\n"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
while True : N, K = map(int, input().split()) if N == 0 and K == 0 : break S = list(map(int, input().split())) total_B = [0] * K for i in range(N) : B = list(map(int, input().split())) for j in range(K) : total_B[j] += B[j] ans = 'Yes' for i in range(K) : if S[i] < total_B[i] : ans = 'No' break print(ans)
PYTHON3
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(true){ int N = in.nextInt(); int K = in.nextInt(); if(N == 0 && K == 0) break; int [] S = new int [K]; boolean judge = true; for(int i = 0; i < K; i++){ S[i] = in.nextInt(); } for(int i = 0; i < N; i++){ for(int m = 0; m < K; m++){ S[m] -= in.nextInt(); if(S[m] < 0) judge = false; } } if(judge)System.out.println("Yes"); else System.out.println("No"); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.io.*; import java.util.StringTokenizer; class Main { public static void main(String args[]) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String buf; try { while (!(buf = br.readLine()).equals("0 0")) { StringTokenizer st = new StringTokenizer(buf); int N = Integer.parseInt(st.nextToken()); int K = Integer.parseInt(st.nextToken()); st = new StringTokenizer(br.readLine()); int type[] = new int[K]; boolean able = true; for (int i=0;i<K;i++) { type[i] = Integer.parseInt(st.nextToken()); } for (int i=0;i<N;i++) { st = new StringTokenizer(br.readLine()); for (int j=0;j<K;j++) { type[j] -= Integer.parseInt(st.nextToken()); if (type[j]<0) { able = false; } } } if (able) System.out.println("Yes"); else System.out.println("No"); } } catch (Exception e) { e.printStackTrace(); } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
//58 #include<iostream> #include<algorithm> using namespace std; int main(){ for(int N,K;cin>>N>>K,N|K;){ int s[100]; for(int i=0;i<K;i++){ cin>>s[i]; } bool fail=false; for(int i=0;i<N;i++){ for(int j=0;j<K;j++){ int b; cin>>b; s[j]-=b; if(s[j]<0){ fail=true; } } } cout<<((fail)?"No":"Yes")<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main() { int n,k,i,j; int b[1012]; for(;;) { cin >> n >> k ; if(n==0 && k==0) break; for(i=0;i<k;i++) cin >> b[i] ; int a,flag=1; for(i=0;i<n;i++) { for(j=0;j<k;j++) { cin >> a ; b[j]-=a; if(b[j]<0) flag=0; } } if(flag==1) cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
// AOJ 1019 #include<cstdio> #define rep( i, a ) for( int i = 0; i != (a); ++i ) int N, K; int S[100]; int B[100][100]; int main() { while( scanf( "%d%d", &N, &K ), N|K ) { rep( i, K ) scanf( "%d", S+i ); rep( i, N ) rep( j, K ) scanf( "%d", &B[i][j] ); bool fl = true; rep( i, K ) { int sum = 0; rep( j, N ) sum += B[j][i]; if( sum > S[i] ) { fl = false; break; } } puts( fl ? "Yes" : "No" ); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<cstdio> using namespace std; int main(){ int h,i,j; int n,m; while(scanf("%d%d",&n,&m),n||m){ int s[100]; for(i=0;i<m;++i) scanf("%d",s+i); h=1; for(i=0;i<n;++i){ for(j=0;j<m;++j){ int b; scanf("%d",&b); if(h){ s[j]-=b; if(s[j]<0) h=0; } } } if(h) puts("Yes"); else puts("No"); } 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> bool check(int m,int k) { int blood[101]; int eats[101]={0}; for(int i=0;i<k;i++) scanf("%d",&blood[i]); for(int i=0;i<m;i++) { for(int j=0;j<k;j++) { int temp; scanf("%d",&temp); eats[j]+=temp; } } for(int i=0;i<k;i++) if(eats[i]>blood[i]) return false; return true; } int main() { int member,kind; while(true) { scanf("%d %d",&member,&kind); if(member==0 && kind==0) break; check(member,kind) ? printf("Yes\n") : printf("No\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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; while (cin >> N >> K && (N || K)) { vector<int> S(K); for (int i=0; i<K; ++i) cin >> S[i]; int t; bool ok = true; for (int i=0; i<N; ++i) { for (int j=0; j<K; ++j) { cin >> t; S[j] -= t; if (S[j] < 0) { ok = false; } } } cout << (ok ? "Yes" : "No") << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std; int main(){ int n,k,tmp; int s[100]; bool f; while(1){ cin >> n >> k; if(!n && !k)break; for(int i=0;i<k;i++)cin >> s[i]; f = true; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin >> tmp; if(f)s[j] -= tmp; if(s[j] < 0)f = false; } } if(f)cout << "Yes" << endl; else cout << "No" << endl; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); int N, K; while (cin >> N >> K && (N || K)) { vector<int> S(K); for (int i=0; i<K; ++i) cin >> S[i]; int t; bool ok = true; for (int i=0; i<N; ++i) { for (int j=0; j<K; ++j) { cin >> t; S[j] -= t; if (S[j] < 0) { ok = false; } } } cout << (ok ? "Yes" : "No") << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> using namespace std ; int n , k ; int s[101] , b[101] ; int f(){ for( int i=0 ; i<k ; i++ ) if( s[i]-b[i] < 0 ) return 1 ; return 0 ; } int main(){ int a ; while(1){ cin >> n >> k ; if( n==0 && k==0 ) break ; for( int i=0 ; i<101 ; i++ ) b[i] = 0 ; for( int i=0 ; i<k ; i++ ) cin >> s[i] ; for( int i=0 ; i<n ; i++ ){ for( int j=0 ; j<k ; j++ ){ cin >> a ; b[j] += a ; } } if( f() == 0 ) cout << "Yes" << endl ; else cout << "No" << 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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include <iostream> #include <vector> #include <string> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <cmath> #include <cassert> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = a; i < (b); ++i) #define ALL(c) (c).begin(), (c).end() int S[110]; int main() { int N, K; while (cin >> N >> K, N | K) { REP(i, K) { cin >> S[i]; } REP(i, N) { REP(j, K) { int b; cin >> b; S[j] -= b; } } REP(i, K) { if (S[i] < 0) { cout << "No" << endl; goto next; } } cout << "Yes" << endl; next:; } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<iostream> #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,k,b; while(cin>>n>>k,n && k){ int s[k]; rep(i,k)cin>>s[i]; bool check=true; rep(i,n){ rep(j,k){ cin>>b; s[j]-=b; if(s[j]<0)check=false; } } if(check)cout<<"Yes"<<endl; else cout<<"No"<<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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
#include<stdio.h> #include <iostream> using namespace std; int main() { while (1) { int n, k; int s[100], b[100]; bool bo = true; scanf("%d %d", &n, &k); if (n == 0 && k == 0) break; for (int i = 0; i < k; ++i) { scanf("%d", &s[i]); } for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { scanf("%d", &b[j]); s[j] -= b[j]; if (s[j] < 0) bo = false; } } if (bo) printf("Yes\n"); else printf("No\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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] blood; int n=0,k=0; boolean ok = true; while(sc.hasNext()){ n = sc.nextInt(); k = sc.nextInt(); if(n==0 && k==0) break; blood = new int[k]; for(int i = 0;i<k;i++) blood[i] = sc.nextInt(); for(int i = 0;i<n;i++){ for(int j = 0;j<blood.length;j++){ blood[j] -= sc.nextInt(); if(blood[j]<0) ok = false; } } System.out.println(ok ? "Yes" : "No"); ok = true; } } }
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 of the family, are looking inside a fridge to prepare dinner. Your first task is to write a program that judges if all family members' dinner can be prepared using blood in the fridge. Constraints * Judge data includes at most 100 data sets. * 1 ≤ N ≤ 100 * 1 ≤ K ≤ 100 * 0 ≤ Si ≤ 100000 * 0 ≤ Bij ≤ 1000 Input Input file consists of a number of data sets. One data set is given in following format: N K S1 S2 ... SK B11 B12 ... B1K B21 B22 ... B2K : BN1 BN2 ... BNK N and K indicate the number of family members and the number of blood types respectively. Si is an integer that indicates the amount of blood of the i-th blood type that is in a fridge. Bij is an integer that indicates the amount of blood of the j-th blood type that the i-th vampire uses. The end of input is indicated by a case where N = K = 0. You should print nothing for this data set. Output For each set, print "Yes" if everyone's dinner can be prepared using blood in a fridge, "No" otherwise (without quotes). Example Input 2 3 5 4 5 1 2 3 3 2 1 3 5 1 2 3 4 5 0 1 0 1 2 0 1 1 2 2 1 0 3 1 1 0 0 Output Yes No
7
0
import java.util.*; public class Main { static Scanner kbd = new Scanner(System.in); public static void main(String[] args) { while(kbd.hasNext()){ int n = kbd.nextInt(); int k = kbd.nextInt(); boolean answer = true; int i; if(n!=0 && k!=0){ int[] blood = new int[k]; for(i=0; i<blood.length; i++){ blood[i] = kbd.nextInt(); } for(; n>0; n--){ for(i=0; i<blood.length; i++){ blood[i] -= kbd.nextInt(); if(blood[i]<0) answer = false; } } if(answer) System.out.println("Yes"); else System.out.println("No"); } } } }
JAVA