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
#include <iostream> using namespace std; int s[100]; int main() { int n,k; while(cin >> n >> k){ if(!n && !k) break; bool flag = true; 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 a; cin >> a; s[j] -= a; if(s[j] < 0) flag = false; } } 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> using namespace std; int main() { int n,m; while(cin >> n >> m && (n||m)) { int a[m],b[m]; for(int i=0; i<m; i++) { cin >> a[i]; b[i]=0; } for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { int x; cin >> x; b[j]+=x; } } bool ck=true; for(int i=0; i<m; i++) { if(a[i]<b[i]) ck=false; } if(ck) 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.util.*; public class Main{ public static void main(String[] args){ new Main().run(); } Scanner sc = new Scanner(System.in); int n, k; int[] blood; boolean ans; void run(){ while(sc.hasNext()){ n = sc.nextInt(); k = sc.nextInt(); if(n==0 && k==0) break; blood = new int[k]; ans = true; for(int i=0; i<k; i++) blood[i] = sc.nextInt(); for(int i=0; i<n; i++) for(int j=0; j<k; j++){ blood[j] -= sc.nextInt(); if(blood[j]<0) ans = false; } System.out.println(ans ? "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
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 = ""; StringTokenizer st; StringBuilder sb = new StringBuilder(); next: while ((line = br.readLine()) != null && !line.isEmpty()) { int n = Integer.parseInt(line.substring(0, line.indexOf(' '))); int k = Integer.parseInt(line.substring(line.indexOf(' ') + 1)); if (n == 0 && k == 0) { break; } int[] stock = new int[k]; int[] 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
import java.util.Arrays; 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) break; int[] amountInFridge = new int[k]; int[][] amountNeed = new int[n][k]; boolean isEnough = true; for(int i =0; i<k; i++){ amountInFridge[i] = sc.nextInt(); } for (int i=0; i<n; i++){ for(int j=0; j<k; j++){ amountNeed[i][j] = sc.nextInt(); } } OUT: for (int j =0 ; j<k; j++){ int sum = amountNeed[0][j]; for (int i=1; i<n; i++){ sum+= amountNeed[i][j]; if (sum > amountInFridge[j]) { isEnough = false; break OUT; } } } if(isEnough) 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 <string> #include <vector> using namespace std; int main() { 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> #include <vector> #include <algorithm> #include <stdio.h> using namespace std; int i, j, n, k, s[100], b[100][100]; int main(void) { while(1) { scanf("%d%d", &n, &k); if(!n && !k) break; 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[i][j]); s[j] -= b[i][j]; } } bool ok = true; for(i = 0; i < k; i++) if(s[i] < 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 <bits/stdc++.h> using namespace std; int a,n,k,i,j,x,s[100]; int main(){ while(cin>>n>>k,n){ for(i=0;i<k;a=0)cin>>s[i++]; for(i=0;i++<n;) for(j=0;j<k;s[j++]-=x)cin>>x; for(i=0;i<k;)s[i++]<0?(a=1):0; cout<<(a?"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
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<set> #include<map> #include<stack> #include<queue> #include<string> #include<cstring> #include<cstdlib> #include<cctype> #include<bitset> #include<functional> #include<climits> using namespace std; typedef pair<int,int>pii; const int INF=1e9; const int dx[]={0,-1,0,1},dy[]={-1,0,1,0}; int main(){ int n,k; while(scanf("%d%d",&n,&k),n||k){ int cnt[100]; for(int i=0;i<k;i++)scanf("%d",&cnt[i]); for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ int val; scanf("%d",&val); cnt[j]-=val; } } bool flag=true; for(int i=0;i<k;i++)flag&=(cnt[i]>=0); puts(flag?"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<stdio.h> int main() { int n,k,a[100],i,x,f; while(scanf("%d%d",&n,&k),n) { for(i=0;i<k;++i)scanf("%d",&a[i]); while(n--)for(i=0;i<k;++i)scanf("%d",&x),a[i]-=x; for(f=i=0;i<k;++i)if(a[i]<0)f=1; puts(f?"No":"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
import java.util.Scanner; /** * Vampirish Night * URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1019&lang=jp * * @author Igari Kazuya */ public class Main { /** * @param args */ public static void main(String[] args) { // TODO ツ篠γ‚₯ツ督ョツ青カツ青ャツ぀ウツγ₯ェツ぀スツδソツッツドツ・ツスツタツブ Scanner sc = new Scanner(System.in); int n,k; while(true){ n = sc.nextInt(); k = sc.nextInt(); if(n==0 && k==0){ break; } int[][] array = new int[n+1][k]; for(int i=0;i<n+1;i++){ for(int j=0;j<k;j++){ array[i][j] = sc.nextInt(); } } for(int i=1;i<n+1;i++){ for(int j=0;j<k;j++){ array[0][j] -= array[i][j]; } } boolean flag = true; for(int i=0;i<k;i++){ if(array[0][i] < 0){ flag = false; } } if(flag){ 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.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,n,k; int s[],b[][],sum[]; boolean flag; while(true){ flag=true; n=sc.nextInt(); k=sc.nextInt(); if(n+k==0) break; s=new int[k]; sum=new int[k]; b=new int[n][k]; for(i=0;i<k;i++){ s[i]=sc.nextInt(); sum[i]=0; } for(i=0;i<n;i++){ for(j=0;j<k;j++){ b[i][j]=sc.nextInt(); } } for(i=0;i<k;i++){ for(j=0;j<n;j++){ sum[i]+=b[j][i]; } } for(i=0;i<k;i++){ //System.out.println(s[i]+" "+sum[i]); if(s[i]<sum[i]){ flag=false; } } if(flag) 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 <vector> using namespace std; int main(){ int n,k,tmp; while(cin >> n >> k,n||k){ bool ju = true; vector <int> blood(k+1); for(int i=1;i<=k;i++) cin >> blood[i]; for(int i=0;i<n;i++){ for(int j=1;j<=k;j++){ cin >> tmp; if(blood[j] < tmp) ju = false; else blood[j] -= tmp; } } cout << ((ju)? "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> #define MAX_K 110 using namespace std; int main(){ int n, k; while(cin >>n >>k){ if(n == 0 && k == 0) break; int dx[MAX_K] = {0}, max[MAX_K] = {0}; for(int i = 0; i < k; i++){ cin >>max[i]; } for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ int tmp; cin >>tmp; dx[j] += tmp; } } bool flag = false; for(int i = 0; i < k; i++){ if(dx[i] > max[i]){ flag = true; break; } } if(flag) cout <<"No"; else cout <<"Yes"; cout <<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
while 1: n,k=map(int,input().split()) if n==0:break a=[int(i) for i in input().split()] for _ in range(n): b=list(map(int,input().split())) for j,c in enumerate(b): a[j]-=c f=0 for i in range(k): if a[i]<0: f=1 break print('No' if f else '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<iostream> using namespace std; int main() { int n, k; while( cin >> n >> k ) { if( n + k == 0 ) break; int* a = new int[k]; int b; for( int i = 0; i < k; i++ ) cin >> a[i]; bool judge = true; for( int i = 0; i < n; i++ ) for( int j = 0; j < k; j++ ) { cin >> b; a[j] -= b; if( a[j] < 0 ) judge = false; } if( judge == 1 ) cout << "Yes" << endl; else cout << "No" << endl; delete a; } 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]; 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 >> tmp; s[j] -= tmp; } } tmp = 1; for(int i=0;i<k;i++){ if(s[i] < 0)tmp = 0; } if(tmp)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; bool flg; while(cin >> n >> k, (n!=0 || k!=0)) { flg = true; int* map = new int[k]; for(int i=0; i < k; i++) cin >> map[i]; for(int i=0; i < n; i++) { for(int j=0; j < k; j++) { int b; cin >> b; map[j] -= b; if(map[j] < 0) flg = false; } } if( flg ) 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> #define SIZE 100 using namespace std; int main() { int n, k, map[SIZE]; bool flg; while(cin >> n >> k, n | k) { flg = true; int* map = new int[k]; for(int i=0; i < k; i++) cin >> map[i]; for(int i=0; i < n; i++) { for(int j=0; j < k; j++) { int b; cin >> b; map[j] -= b; if(map[j] < 0) flg = false; } } if( flg ) 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 <bits/stdc++.h> using namespace std; int main() { int n, k; int s[101]; while (cin >> n >> k, n + k){ bool judge = true; for (int i = 0; i < k; i++) cin >> s[i]; int b; for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ cin >> b; s[j] -= b; } } for (int i = 0; i < k; i++){ if (s[i] < 0) judge = false; } if (judge) cout << "Yes\n"; else cout << "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<algorithm> #include<vector> #include<stack> #include<queue> #include<cstdio> #include<climits> #include<cmath> #include<cstring> #include<string> #define f first #define s second #define mp make_pair #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++) #define ALL(c) (c).begin(), (c).end() using namespace std; typedef unsigned int uint; typedef long long ll; int main(){ int n,k; while(scanf("%d%d",&n,&k),n+k){ int s[k]; REP(i,k) scanf("%d",&s[i]); REP(i,n) REP(j,k){ int b; scanf("%d",&b); s[j] -= b; } bool ans = true; REP(i,k) if(s[i] < 0) ans = false; printf("%s\n",ans?"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 <algorithm> #include <cctype> #include <cstdio> #include <cmath> #include <iostream> #include <functional> #include <queue> #include <string> #include <map> #include <vector> using namespace std; int main() { for (;;) { int N, K; cin >> N >> K; if (!N && !K) return 0; int S[100], s[100]; for (int i = 0; i < K; i++) cin >> S[i]; fill(s, s+K, 0); for (int i = 0; i < N; i++) for (int j = 0; j < K; j++) { int x; cin >> x; s[j] += x; } bool f = true; for (int i = 0; i < K; i++) if (s[i] > S[i]) { f = false; break; } cout << (f ? "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> #include <cstdlib> int main(){ std::vector<int> s; while(true){ s.clear(); int n, k; std::cin >> n >> k; if (n==0 && k==0) return EXIT_SUCCESS; for(int i=0; i<k; i++){ int tmp; std::cin >> tmp; s.push_back(tmp); } for(int i=0; i<n; i++){ for(int j=0; j<k; j++){ int tmp; std::cin >> tmp; s[j] = s[j] - tmp; } } std::cout << [&](){ for(auto i : s){ if(i<0) return "No"; } return "Yes"; }() << std::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(scanf("%d%d", &n, &k), (n|k)){ int blood[100]; for(int i=0 ; i<k ; ++i) scanf("%d", &blood[i]); bool no = false; for(int i=0 ; i<n ; ++i){ for(int j=0 ; j<k ; ++j){ int a; scanf("%d", &a); blood[j] -= a; if(blood[j] < 0) no = true; } } puts(no ? "No" : "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> #include<algorithm> #include<set> #include<map> #include<vector> #include<queue> #include<cstring> #include<cmath> #include<cstdio> #include<cstdlib> using namespace std; #define REP(i,a,n) for(int i = a ; i < n ; i++) #define rep(i,n) REP(i,0,n) typedef long long ll; void solve(){ } int main(){ int n,m; while(cin>>n>>m,n||m){ int s[m]; rep(i,m){ cin>>s[i]; } bool flg = true; rep(i,n){ rep(j,m){ int x; cin>>x; s[j] -= x; if(s[j] < 0) flg = false; } } cout<<(flg ? "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 <stdio.h> int main() { int n, k, s[100], t; while(true) { scanf("%d%d", &n, &k); if(n == 0 && k == 0) break; for(int i = 0; i < k; ++i) { scanf("%d", &t); s[i] = t; } for(int i = 0; i < n; ++i) { for(int j = 0; j < k; ++j) { scanf("%d", &t); s[j] -= t; } } bool empty = false; for(int i = 0; i < k; ++i) { if(s[i] < 0) { empty = true; break; } } if(empty) 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> using namespace std; int main(){ int n,k; int s[100]; bool f; while( cin>>n>>k &&(n||k) ){ for( int i=0;i<k;i++ ) cin >> s[i]; f=true; for( int i=0;i<n;i++ ){ for( int j=0,l;j<k;j++ ){ cin >> l; s[j] -= l; if( s[j]<0 ) f=false; } } if( f ) 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,l; while(1) { cin>>n>>k; if(n==0 && k==0) break; int s[k]; int b[k]; for(int i=0; i<k; i++){ s[i]=0; b[i]=0; cin>>s[i]; } for(int i=0; i<n; i++) for(int j=0;j<k;j++) cin>>l,b[j]+=l; int f=0; for(int i=0; i<k; i++) if(s[i] < b[i]) f=1; if(f==0) cout<<"Yes\n"; else cout<<"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<stdio.h> #include<stdlib.h> #include<iostream> #include<string.h> #include<math.h> #include<algorithm> #include<cstring> #include<queue> using namespace std; #define INF 100000000 int max(int a,int b){ if(a>b){ return a; }else{ return b; } } int main(){ while(1){ int n,k,s[101],b,flg=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++){ cin>>b; if(s[j]<b){ flg=0; }else{ s[j]-=b; } } } if(flg==1){ 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<cstring> #include<algorithm> #include<functional> using namespace std; int main(){ int n,k; int a[100]; while(cin>>n>>k,n|k){ for(int i=0;i<k;i++)cin>>a[i]; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ int b; cin>>b; a[j]-=b; } } bool ans=find_if(a,a+k,bind2nd(less<int>(),0))==a+k; cout<<(ans?"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 <cstdio> int n, k, s[100], b[100]; int main() { while (scanf("%d%d",&n,&k)) { if (!n&&!k) break; for (int i=0; i<k; i++) { scanf("%d",&s[i]); b[i]=0; } for (int i=0; i<n; i++) for (int j=0; j<k; j++) { int x; scanf("%d",&x); b[j]+=x; } bool flag=true; for (int i=0; i<k; i++) if (s[i]<b[i]) flag=false; if (flag) puts("Yes"); else puts("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 n, m, x, s[100]; int main() { while(scanf("%d%d", &n, &m), n + m) { for(int i = 0; i < m; i++) scanf("%d", s + i); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) scanf("%d", &x), s[j] -= x; } int f = 1; for(int i = 0; i < m; i++) { if(s[i] < 0) f = 0; } puts(f ? "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 <vector> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <fstream> #include <complex> #include <math.h> #include <ctype.h> using namespace std; int n,p,s[100],q; bool sw=false; int main(){ while(cin>>n>>p){ if(n==0){break;} for(int i=0;i<p;i++){ cin>>s[i];} for(int ii=0;ii<n;ii++){ for(int iii=0;iii<p;iii++){ cin>>q;s[iii]-=q;}} for(int a=0;a<p;a++){ if(s[a]<0){sw=true;cout<<"No"<<endl;a=1000;}} if(sw==false){cout<<"Yes"<<endl;} sw=false;} 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[101], Bij; for(;cin>>N>>K,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>>Bij; S[j] -= Bij; } } int ok = 1; for (int i = 0; i < K; i++) { if (S[i] < 0) { ok = 0; break; } } 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
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,k,i;(n=s.nextInt())>0;){int[]a=new int[k=s.nextInt()];for(i=0;i<k;++i)a[i]=s.nextInt();for(;n-->0;)for(i=0;i<k;++i)a[i]-=s.nextInt();Arrays.sort(a);System.out.println(a[0]<0?"No":"Yes");}}}
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 <vector> using namespace std; int main() { int n, k; while(cin >> n >> k, n+k) { vector<int> s(k); int b; 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; } } bool ans = true; for(int i = 0; i < k; i++) { if(s[i] < 0) ans = false; } if(ans) 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 <iostream> using namespace std; int main(void){ int n,k; int s[111]; while(cin >> n >> k && n){ for(int i = 0; i < k; i++){ cin >> s[i]; } for(int j = 0; j < n; j++){ for(int i = 0; i < k; i++){ int b; cin >> b; s[i] -= b; } } bool f = true; for(int i = 0; i < k; i++){ if(s[i] < 0){ f = false; cout << "No" << endl; 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 <iostream> #include <vector> using namespace std; int main() { int N, K; while (cin >> N >> K) { if ((N|K) == 0) break; vector<int> S(K), B(K, 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) { int tmp; cin >> tmp; B[j] += tmp; } } bool valid = true; for (int i = 0; i < K && valid; ++i) { if (S[i] < B[i]) valid = false; } if (valid) 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.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 = ""; StringTokenizer st; StringBuilder sb = new StringBuilder(); int[] stock = new int[100]; int[] needs = new int[100]; next: while ((line = br.readLine()) != null && !line.isEmpty()) { int n = Integer.parseInt(line.substring(0, line.indexOf(' '))); int k = Integer.parseInt(line.substring(line.indexOf(' ') + 1)); if ((n | k) == 0) { break; } st = new StringTokenizer(br.readLine()); for (int i = 0; i < k; i++) { stock[i] = Integer.parseInt(st.nextToken()); needs[i] = 0; } 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() { int n, m; while (cin >> n >> m){ if (n == 0 && m == 0)return 0; int q[100]; int p[100] = { 0 }; for (int i = 0; i < m; i++) { cin >> q[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int a; cin >> a; p[j] += a; } } bool b = true; for (int i = 0; i < m; i++) { if (q[i] < p[i]) { b = false; } } if (b)cout << "Yes"; else cout << "No"; cout << 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(true){ cin >> n >> k; if (!n&&!k) break; int s[k]; int b[k]; for(int i=0;i<k;i++){ b[i] = 0; cin >> s[i]; } int bb; for(int j=0;j<n;j++) for(int i=0;i<k;i++) cin >> bb,b[i]+=bb; int ii; for(ii=0;ii<k;ii++) if (s[ii]<b[ii]) break; if (ii==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> #define MAX 110 using namespace std; int main(){ int n,k; while(cin>>n>>k,n||k){ int tab[MAX],s[MAX],x; for(int i=0;i<k;i++) tab[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>>x; tab[j]+=x; }int i; for(i=0;i<k;i++) if(tab[i]>s[i]) 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 <iostream> using namespace std; int B[100]; bool flag; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; int S[100]; while (cin >> N >> K, N + K){ 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++){ int a; cin >> a; B[j] += a; } } flag = true; for (int i = 0; i < K; i++){ if (S[i] < B[i]){ 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
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; 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]) { System.out.println("No"); continue next; } } System.out.println("Yes"); } } }
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<vector> #include<list> #include<algorithm> #include<iostream> #include<string> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; int main(){ int i,j; int s[100],b,m,n; while(cin>>n>>m&&n+m){ for(i=0;i<m;i++) cin>>s[i]; for(i=0;i<n;i++){ for(j=0;j<m;j++){ cin>>b; s[j]-=b; } } for(i=0;i<m;i++){ if(s[i]<0) break; } if(i==m) 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> using namespace std; int main(){ int n,k,t; while(cin >> n >> k && n || k){ bool flag = true; vector<int> blood(k); for(int i=0;i<k;i++){ cin >> blood[i]; } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin >> t ; blood[j]-=t; if(blood[j]<0)flag = false; } } if(flag)cout << "Yes"; else cout << "No"; cout << 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; while(cin >> n >> k){ if(n + k == 0) break; 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++){ cin >> b; s[j] -= b; } } bool judge = true; for(int i = 0; i < k; i++) if(s[i] < 0) judge = false; if(judge) 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
while True: N, K = map(int, input().split()) if N == 0: break S = [0] + list(map(int, input().split())) flag = True for _ in range(N): B = list(map(int, input().split())) for i, b in enumerate(B): S[i+1] -= b if S[i+1] < 0: flag = False break print("Yes" if flag 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
import java.util.*; public class Main{ public static void main(String[] args){ int N,K,x,flg; int t[] = new int[100]; Scanner scan = new Scanner(System.in); while(true){ N=scan.nextInt(); K=scan.nextInt(); if(N==0&&K==0)break; flg=1; for(int i=0;i<K;i++)t[i]=scan.nextInt(); for(int i=0;i<N;i++){ for(int j=0;j<K;j++){ x=scan.nextInt(); t[j]-=x; if(t[j]<0)flg=0; } } if(flg==1){ 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 <cstdio> #include <algorithm> #include <array> #include <vector> using namespace std; int main() { while ( true ) { int n, k; cin >> n >> k; if ( n == 0 && k == 0 ) break; vector<int> s( k ), sum( 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 val; cin >> val; sum[ j ] += val; } } bool success = true; for ( int i = 0; success && i < k; i++ ) { if ( s[ i ] < sum[ i ] ) { success = false; } } if ( success ) { 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 True: n, k = map(int, input().split()) if n + k == 0: break s = list(map(int, input().split())) for _ in range(n): b = list(map(int, input().split())) for j, _b in enumerate(b): s[j] = s[j] - _b bool_list = list(map(lambda x: x >= 0,s)) if False in bool_list: print('No') 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 <iostream> #include <vector> using namespace std; int main( void ) { int N, K; while ( cin >> N >> K && N != 0 && K != 0 ) { vector <int> S( K ); for ( int i = 0; i < K; i++ ) { cin >> S[i]; } for ( int lpc = 0; lpc < N; lpc++ ) { for ( int i = 0; i < K; i++ ) { int B; cin >> B; S[i] -= B; } } bool ok = true; for ( int i = 0; i < K; i++ ) { if ( S[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
while True: n,k = map(int,raw_input().split()) if n == 0 and k == 0: break fridge = map(int,raw_input().split()) judge = False for i in xrange(n): uses = map(int,raw_input().split()) for j in xrange(k): fridge[j] -= uses[j] if fridge[j] < 0: judge = True if judge: print "No" else: print "Yes"
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
import java.util.Scanner; public 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 blood[]=new int [k]; for(int i=0;i<k;i++) blood[i]=sc.nextInt(); int vamp_b[][]=new int[n][k]; int max_b[]=new int[k]; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ vamp_b[i][j]=sc.nextInt(); max_b[j]+=vamp_b[i][j]; } } String ans="Yes"; for(int i=0;i<k;i++){ if(max_b[i]>blood[i])ans="No"; // System.out.println(max_b[i]+" "+blood[i]); } System.out.println(ans); } } }
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<algorithm> #include<cstdio> #include<cmath> #include<math.h> #include<string> #include<string.h> #include<stack> #include<queue> #include<vector> #include<utility> #include<set> #include<map> #include<stdlib.h> #include<iomanip> using namespace std; #define ll long long #define ld long double #define EPS 0.0000000001 #define INF 1e9 #define MOD 1000000007 #define rep(i,n) for(i=0;i<n;i++) #define loop(i,a,n) for(i=a;i<n;i++) #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) typedef vector<int> vi; typedef pair<int,int> pii; int main(void) { int i,j; int n,k,t; while(1){ cin>>n>>k; if(n==0 && k==0)break; vi s(k),a(k,0); rep(i,k)cin>>s[i]; rep(i,n){ rep(j,k){ cin>>t; a[j]+=t; } } rep(i,k)if(s[i]<a[i]){ cout<<"No"<<endl; break; } if(i==k)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
import java.util.*; public 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[][] map = new int[n+1][k]; for(int i=0;i<n+1;i++) for(int j=0;j<k;j++) map[i][j] = sc.nextInt(); int sum = 0; boolean flag = true; for(int i=0;i<k;i++){ sum = 0; for(int j=1;j<n+1;j++) sum += map[j][i]; if(sum>map[0][i]){ flag = false; break; } } if(flag==true) 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> using namespace std; int main(){ int n,k; int s[100],b; while(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++){ cin >> b; s[j] -= b; } } bool ans = true; for(int i=0;i<k;i++){ if(s[i] < 0)ans = false; } if(ans)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,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; 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
while True: n,k = map(int, input().split()) if n == k == 0: break s = list(map(int, input().split())) for _ in range(n): b = list(map(int, input().split())) for i in range(k): s[i] -= b[i] print("Yes" if min(s) >= 0 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> #include<vector> #include<string> #include<algorithm> using namespace std; int main() { int a, b; while (cin >> a >> b, a | b) { vector<int>s(b); for (int c = 0; c < b; c++)cin >> s[c]; for (int d = 0; d < a; d++) { for (int e = 0; e < b; e++) { int f; cin >> f; s[e] -= f; } } for (int g = 0; g < b; g++) { if (s[g] < 0) { cout << "No" << endl; break; } if (b - 1 == g)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 <vector> using namespace std; int main(){ int n,k,t; vector<int> b; while(cin >> n >> k && n || k){ bool f=false; b.clear(); for(int i=0;i<k;i++){ cin >> t; b.push_back(t); } for(int i=0;i<n;i++){ for(int i=0;i<k;i++){ cin >> t; b[i]-=t; if(b[i]<0)f=1; } } cout << (f ? "No" : "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
import java.util.Scanner; //Vampirish Night public class Main{ void run(){ 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(); boolean f = true; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ int x = sc.nextInt(); if(s[j]<x)f = false; s[j]-=x; } } System.out.println(f?"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 <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <map> #include <set> #include <cstdio> #include <cmath> #define rep(i,l,n) for(lint i=l;i<n;i++) #define rer(i,l,n) for(lint i=l;i<=n;i++) #define all(a) a.begin(),a.end() #define o(a) cout<<a<<endl #define pb(a) push_back(a) #define mk(a,b) make_pair(a,b) #define fi first #define se second using namespace std; typedef long long lint; typedef vector<int> vi; typedef vector<lint> vli; typedef vector<vi> vvi; typedef pair<int,int> pii; int main(){ int n,k; while(1){ cin>>n>>k; if(n+k==0) break; vi s(k),d(k); rep(i,0,k) cin>>s[i]; rep(i,0,n){ rep(j,0,k){ int a; cin>>a; d[j]+=a; } } rep(i,0,k){ if(s[i]<d[i]){ o("No"); break; } if(i==k-1) o("Yes"); } } }
CPP
p00605 Vampirish Night
There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each blood type. You, cook 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> #include <string> #include <cstring> #include <cstdio> #include <queue> #include <stack> #include <map> #include <set> #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(v) (v).begin(), (v).end() #define rev(s) (s).rbegin(), (s).rend() #define MP make_pair #define X first #define Y second using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 100000000; int main(){ while(1){ int n, k; cin >> n >> k; if(!(n+k))break; vector<int> s(k); rep(i, k){ cin >> s[i]; } rep(i, n){ rep(j, k){ int b; cin >> b; s[j] -= b; } } sort(all(s)); cout << (s[0] >= 0? "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() { while(true) { int N, K; cin >> N >> K; if(!N && !K) break; vector<int> s(K); for(int i = 0; i < K; ++i) cin >> s[i]; bool ok = true; while(N--) { for(int i = 0; i < K; ++i) { int b; cin >> b; s[i] -= b; if(s[i] < 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
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { new Main().run(); } private void run() throws IOException { Scanner scanner = new Scanner(System.in); while (true) { int n = scanner.nextInt(); int k = scanner.nextInt(); if ((n | k) == 0) break; int[] num = new int[k]; for (int i = 0; i < k; i++) num[i] = scanner.nextInt(); String ans = "Yes"; for (int i = 0; i < n; i++) for (int j = 0; j < k; j++) { int a = scanner.nextInt(); num[j] -= a; if (num[j] < 0) ans = "No"; } System.out.println(ans); } } }
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 <vector> using namespace std; void solve() { int N, K; while(cin >> N >> K, N || K) { vector<int> S(K); for(int i = 0; i < K; ++i) { cin >> S[i]; } vector< vector<int> > B(N, vector<int>(K)); for(int i = 0; i < N; ++i) { for(int j = 0; j < K; ++j) { cin >> B[i][j]; } } bool ok = true; vector<int> Sum(K); for(int i = 0; i < K; ++i) { for(int j = 0; j < N; ++j) { Sum[i] += B[j][i]; } if(S[i] < Sum[i]) { ok = false; } } if(ok) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } int main() { 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
import java.util.Scanner; public class Main{ public static void main(String[] args){ new Main().run(); } public void run(){ Scanner scan = new Scanner(System.in); while(scan.hasNext()){ int n = scan.nextInt(); int k = scan.nextInt(); if(n == 0 && k == 0){ break; } int[] s = new int[k]; for(int i = 0;i < k;i++){ s[i] = scan.nextInt(); } for(int i = 0;i < n;i++){ for(int j = 0;j < k;j++){ s[j] -= scan.nextInt(); } } boolean fl = true; for(int i = 0;i < k;i++){ if(s[i] < 0){ fl = false; break; } } System.out.println((fl)?"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> #include <vector> #include <algorithm> #include <functional> using namespace std; int main() { int N, K; while (cin >> N >> K && N != 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 x; cin >> x; s[j] -= x; } } if (find_if(s.begin(), s.end(), bind2nd(less<int>(), 0)) == s.end()) { 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> using namespace std; void solve() { int N, K; while(cin >> N >> K, N || K) { vector<int> blood(K); for(int i = 0; i < K; ++i) { cin >> blood[i]; } vector<int> sum(K); for(int i = 0; i < N; ++i) { for(int j = 0; j < K; ++j) { int require; cin >> require; sum[j] += require; } } bool flag = true; for(int i = 0; i < K; ++i) { if(sum[i] > blood[i]) { flag = false; break; } } if(flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } int main() { 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> #include <vector> using namespace std; void solve() { int N, K; while(cin >> N >> K) { if(!N && !K) { break; } vector<int> S(K); vector<vector<int> > B(N); for(int i = 0; i < N; ++i) { B[i].resize(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 flag = true; 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) { flag = false; break; } } if(flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } int main() { 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 <bits/stdc++.h> using namespace std; int main() { int N, M; while (cin >> N >> M, N || M) { vector<int> d(M); for (auto& i : d) cin >> i; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { int x; cin >> x; d[j] -= x; } } bool ans = true; for (auto i : d) { if (i < 0) ans = false; } cout << (ans ? "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 <cstdio> using namespace std; int main(void) { for(;;){ int n,k; scanf("%d %d",&n,&k); if(n==0 && k == 0)return 0; int blood[k]; for(int i=0;i<k;i++){ scanf("%d",&blood[i]); } bool sucsses=true; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ int tmp; scanf("%d",&tmp); blood[j]-=tmp; if(blood[j]<0){sucsses=false;} } } if(sucsses) printf("Yes\n"); else printf("No\n"); } return 1; }
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; #define REP(i,n) for(int i = 0; i < (int)(n); ++i) int main() { int n, k; while (cin>>n>>k , n|k) { vector<int> s(k); REP(i,k) cin>>s[i]; REP(j,n) REP(i,k) { int tmp; cin>>tmp; s[i] -= tmp; } bool ok = true; REP(i,k) if (s[i] < 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> #include <algorithm> using namespace std; int main(){ int n,k; while(cin>>n>>k,n){ int data[100]; int ans=1; int tmp; for(int i=0;i<k;i++)cin>>data[i]; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin>>tmp; data[j]-=tmp; if(data[j]<0)ans=0; } } if(ans)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,s[100000]={0},bb,i,j; while(1){ cin>>n>>k; if(n==0&&k==0) break; for(i=0;i<k;i++){ cin>>s[i]; } for(i=0;i<n;i++){ for(j=0;j<k;j++){ cin>>bb; s[j]-=bb; } } bb=0; for(i=0;i<k;i++){ if(s[i]<=-1) bb++; } if(bb==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> using namespace std; int main(){ int n, k; while(cin >>n >>k){ if(n == 0 && k == 0) break; vector<int> s(k, 0), b(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 tmp; cin >>tmp; b[j] += tmp; } } bool okFlg = true; for(int i = 0; i < k; i++){ if(s[i] < b[i]){ okFlg = false; break; } } if(okFlg) 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
public class Main{ public void run(java.io.InputStream in, java.io.PrintStream out){ java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int n, k; int[] s; int[][] b; int i, j; for(;;){ n = sc.nextInt(); k = sc.nextInt(); if(n == 0 && k == 0)break; s = new int[k]; b = new int[n][k]; for(i = 0;i < k;i++)s[i] = sc.nextInt(); for(i = 0;i < n;i++)for(j = 0;j < k;j++)b[i][j] = sc.nextInt(); for(i = 1;i < n;i++)for(j = 0;j < k;j++)b[0][j] += b[i][j]; for(i = 0;i < k;i++)if(s[i] < b[0][i])break; if(i < k)System.out.println("No"); else System.out.println("Yes"); } sc.close(); } public static void main(String[] args){ (new Main()).run(System.in, System.out); } }
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
if __name__ == '__main__': while True: N, K = list(map(int, input().strip().split())) if N == 0 and K == 0: break lims = list(map(int, input().strip().split())) totals = [ 0 for _ in range(K) ] for _ in range(N): arr = list(map(int, input().strip().split())) for i in range(K): totals[i] += arr[i] tarimasu = True for i in range(K): if totals[i] > lims[i]: tarimasu = False break print("Yes" if tarimasu 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 <stdio.h> int n, m, x, s[100]; int main() { while(scanf("%d%d", &n, &m), n + m) { for(int i = 0; i < m; i++) scanf("%d", s + i); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) scanf("%d", &x), s[j] -= x; } int f = 1; for(int i = 0; i < m; i++) { if(s[i] < 0) { f = 0; break; } } puts(f ? "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(){ long long int N,K,S[101]={},a,flag=0; while(1){ 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 >> a; S[i] -= a; } } flag = 0; for(int i=0;i<K;i++){ if(S[i]<0){ flag++; break; } } if(!flag){ 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> #include<vector> using namespace std; int main(){ int n,k; while(1){ cin >> n >> k; if(n==0&&k==0) break; vector<int> s; for(int i=0;i<k;++i){ int tmp; cin >> tmp; s.push_back(tmp); } vector<int> b(k,0); for(int i=0;i<n;++i){ for(int j=0;j<k;++j){ int tmp; cin >> tmp; b[j] += tmp; } } bool ans=true; for(int i=0;i<k;++i){ //cout << s[i] << " " << b[i] << endl; if(s[i]-b[i]<0){ ans = false; break; } } cout << (ans?"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> #include <algorithm> using namespace std; int main() { while ( true ) { int N, K; cin >> N >> K; if ( N == 0 && K == 0 ) break; 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 t; cin >> t; S[j] -= t; } if ( *min_element( S.begin(), S.end() ) >= 0 ) 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; #define N_MAX 100 #define K_MAX 100 int blood[K_MAX]; int family[K_MAX]; int n,k; void solve(){ int tmp; for(int i=0;i<k;i++){ cin>>blood[i]; family[i]=0; } for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin>>tmp; family[j]+=tmp; } } for(int i=0;i<k;i++){ if(family[i]>blood[i]){ cout<<"No"<<endl; return ; } } cout<<"Yes"<<endl; return ; } int main(){ while(cin>>n>>k&&(n||k)){ 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<stdio.h> int main(){ int fami,kind,need[100],chi[100]; int i,j,judge=0,temp; for(;;judge=0){ for(i=0;i<100;i++){ need[i]=0; chi[i]=0; } scanf("%d%d", &fami, &kind); if(fami==0&&kind==0)break; for(i=0;i<kind;i++)scanf("%d", &chi[i]); for(i=0;i<fami;i++){ for(j=0;j<kind;j++){ scanf("%d", &temp); need[j]+=temp; } } for(i=0;i<kind;i++){ if(chi[i]-need[i]<0){ judge=1; break; } } if(judge==0)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 <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int s[200]; int b[200][200]; int sum[200]; int main(){ int N, K; while(true){ 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[i][j]; sum[j] += b[i][j]; } } for(int i = 0; i < K; i++){ if(s[i] < sum[i]){ printf("No\n"); break; } if(i == K - 1){ 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> using namespace std; int main() { int N,K; while(1) { cin >> N; cin >> K; int temp; if(N == 0 && K==0)break; int *A = new int[K]; int *B = new int[K]; bool flag = true; for(int i=0;i<K;i++) { B[i] = 0; } for(int i=0;i<K;i++) { cin >> A[i]; } for(int i=0;i<N;i++) { for(int i=0;i<K;i++) { cin >> temp; B[i] += temp; } } for(int i=0;i<K;i++) { if(B[i]>A[i]) { flag = false; break; } } if(flag == false) { 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 <vector> #include <cmath> using namespace std; int remainBlood[101]; int main() { int n, k; while(cin >> n >> k, n || k) { for (int i = 0; i < k; i++) { cin >> remainBlood[i]; } bool satisfied = true; for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { int amo; cin >> amo; remainBlood[j] -= amo; if(remainBlood[j] < 0) { satisfied = false; } } } cout << (satisfied ? "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,s[100],b[100][100]; bool flag1,flag2; while(cin >>n >>k && n!=0 && k!=0){ flag2=true; for(int j=0;j<k;j++) cin >>s[j]; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ cin >> b[i][j]; if(s[j] >= b[i][j]){ s[j]-= b[i][j]; flag1=true;} else{ flag2=false; } } } if(flag2 ==false) cout<<"No"<<endl; else if(flag1 ==true) 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; #define for_(i,a,b) for(int i=(a);i<(b);++i) int N, K, S[102]; void solve() { for_(i,0,K) cin >> S[i]; for_(i,0,N) for_(j,0,K) { int B; cin >> B; S[j] -= B; } bool flag = true; for_(i,0,K) flag &= (S[i] >= 0); puts(flag ? "Yes" : "No"); } int main() { while (cin >> N >> K, N) { solve(); } }
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 != 0 && k != 0){ bool flug = false; vector<int> blood_stock(k); for(int i=0; i<k; i++){ cin >> blood_stock[i]; } for(int i=0; i<n; i++){ for(int j=0; j<k; j++){ int tmp; cin >> tmp; blood_stock[j] -= tmp; } } for(int i=0; i<k; i++){ if(blood_stock[i] < 0){ cout << "No" << endl; flug = true; break; } } if(flug == false){ 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
while True: n,k = map(int, input().split()) if n == k == 0: break s = [int(x) for x in input().split()] for _ in range(n): b = [int(x) for x in input().split()] for i in range(k): s[i] -= b[i] print("Yes" if min(s) >= 0 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
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 1 #define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;} #define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;} #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define each(it,c) for(auto it=(c).begin();it!=(c).end();it++) #define all(c) c.begin(),c.end() const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9 + 7); signed main() { int n, k; while (cin >> n >> k, n || k) { vector<int>s(k, 0); vector<vector<int>>b(k, vector<int>(n)); rep(i, 0, k)cin >> s[i]; rep(i, 0, n) rep(j, 0, k)cin >> b[j][i]; rep(j, 0, k) { if (accumulate(all(b[j]), 0) > s[j]) { cout << "No" << endl; goto here; } } cout << "Yes" << endl; here:; } 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> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) range(i,0,b) #define pb(a) push_back(a) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; using namespace std; int main(){ int n,k; while(cin >> n >> k, n||k){ int s[105]; bool c = true; rep(i,k) cin >> s[i]; rep(i,n){ rep(j,k){ int inp; cin >> inp; s[j]-=inp; if(s[j] < 0) c = false; } } if(c) 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 "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; const ld eps = 1e-9; //// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt" int main() { while (1) { int N, K; cin >> N >> K; if (!N)break; vector<int>ss(K); for (int i = 0; i < K; ++i) { cin >> ss[i]; } for (int i = 0; i < N; ++i) { for (int j = 0; j < K; ++j) { int a; cin >> a; ss[j] -= a; } } bool ok = all_of(ss.begin(), ss.end(), [](const int a) { return a >= 0; }); 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 <iostream> #include <stdlib.h> using namespace std; int main(int argc, char **argv) { int *a, n, k, t; while(1){ cin >> n >> k; if(n == 0){ break; } if(k == 1){ a = (int *)calloc(2, sizeof(int)); } else { a = (int *)calloc(k, sizeof(int)); } for(int i = 0; i < k; i++){ cin >> t; a[i] = t; } for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ cin >> t; a[j] -= t; } } t = 0; for(int i = 0; i < k; i++){ if(a[i] < 0){ t = 1; break; } } cout << ((t == 0)? "Yes" : "No") << endl; free(a); } 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 <cstdlib> #include <cstring> int main(void) { while(true) { int N, K; scanf("%d %d", &N, &K); if(N == 0 && K == 0) break; int blood[100]; // int **order = (int **)calloc(N, sizeof(int)); //int *order = (int *)calloc(N, sizeof(int)); /*for(int i = 0; i < N; i++) order[i] = (int *)calloc(K, sizeof(int)); */ for(int i = 0; i < K; i++) { scanf("%d", &blood[i]); } for(int i = 0; i < N; i++) { for(int j = 0; j < K; j++) { int order; scanf("%d", &order); blood[j] -= order; } } bool flag = true; for(int i = 0; i < K; i++) { if(blood[i] < 0) flag = false; } if(flag == true) 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
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 = ""; StringTokenizer st; StringBuilder sb = new StringBuilder(); next: while ((line = br.readLine()) != null && !line.isEmpty()) { int n = Integer.parseInt(line.substring(0, line.indexOf(' '))); int k = Integer.parseInt(line.substring(line.indexOf(' ') + 1)); if ((n | k) == 0) { break; } int[] stock = new int[k]; int[] 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
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++) { if (isYes) { s[j] -= in.nextInt(); isYes = s[j] >= 0; } else { in.next(); } } } 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
#include<iostream> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) const int maxn = 100; const int maxk = 100; int n,k; long long s[maxk]; int main() { while(cin >> n >> k) { if(n==0 && k==0) break; rep(i,k) cin >> s[i]; int t; rep(j,n)rep(i,k) { cin >> t; s[i] -= t; } int flg = 1; rep(i,k)if(s[i]<0) flg = 0; if(flg) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
CPP