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));
StringBuilder sb = new StringBuilder();
int cases=1;
while (true) {
StringTokenizer st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
if (x <0) {
break;
}
sb.append("Case ").append(cases).append(":\n");
st = new StringTokenizer(br.readLine());
int []month=new int[13];
month[0]=x;
for(int i=1;i<13;i++){
month[i]=Integer.parseInt(st.nextToken());
}
int sum=x;
st = new StringTokenizer(br.readLine());
for(int i=1;i<13;i++){
int temp=Integer.parseInt(st.nextToken());
if(sum>=temp){
sb.append("No problem! :D\n");
sum-=temp;
}else{
sb.append("No problem. :(\n");
}
sum+=month[i];
}
cases++;
}
System.out.print(sb);
}
}
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));
StringBuilder sb = new StringBuilder();
int cases=1;
while (true) {
StringTokenizer st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
if (x <0) {
break;
}
sb.append("Case ").append(cases).append(":\n");
st = new StringTokenizer(br.readLine());
int []month=new int[13];
month[0]=x;
for(int i=1;i<13;i++){
month[i]=Integer.parseInt(st.nextToken());
}
int sum=x;
st = new StringTokenizer(br.readLine());
for(int i=1;i<13;i++){
int temp=Integer.parseInt(st.nextToken());
if(sum>=temp){
sb.append("No problem! :D\n");
sum-=temp;
}else{
sb.append("No problem. :(\n");
}
sum+=month[i];
}
cases++;
}
System.out.print(sb);
}
}
No comments:
Post a Comment