Created
March 3, 2018 10:26
-
-
Save johirbuet/b37180794bb29aa374931ce258ad06c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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