Skip to content

Instantly share code, notes, and snippets.

@johirbuet
Created March 3, 2018 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johirbuet/b37180794bb29aa374931ce258ad06c3 to your computer and use it in GitHub Desktop.
Save johirbuet/b37180794bb29aa374931ce258ad06c3 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class UVA11608 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int c = 1;
while(sc.hasNextInt()) {
int p = sc.nextInt();
if( p == -1) {
break;
}
int [] P = new int[13];
P[0] = p;
for(int i = 1 ;i <= 12; i++) {
P[i] = sc.nextInt();
}
for(int i = 0;i< 12 ;i++) {
int x = sc.nextInt();
int r = 0;
if(x <= P[i]) {
P[i] = P[i] - x;
r = P[i];
}else {
r = P[i];
P[i] = -1;
}
if(r > 0) {
P[i+1] += r;
}
}
System.out.println("Case "+c+":");
for(int i = 0 ; i < 12 ; i++) {
if(P[i] >= 0) {
System.out.println("No problem! :D");
}else {
System.out.println("No problem. :(");
}
}
c++;
}
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment