Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ak47 – 2700
- awp – 4750
- sg553 – 3500
- grenade – 300
- flash – 250
- glock – 500
- bazooka – 5600
- */
- $numItems = intval(readline());
- $moneyNiki = intval(readline());
- if ($numItems > 7){
- printf("Sorry, you can't carry so many things!\n");
- return false;
- }
- $moneyAll = 0;
- for($i = 0; $i < $numItems; $i++){
- $guns = readline();
- if ($guns == "ak47"){
- $moneyAll += 2700;
- }elseif($guns == "awp"){
- $moneyAll += 4750;
- }elseif($guns == "sg553"){
- $moneyAll += 3500;
- }elseif($guns == "grenade"){
- $moneyAll += 300;
- }elseif($guns == "flash"){
- $moneyAll += 250;
- }elseif($guns == "glock"){
- $moneyAll += 500;
- }elseif($guns == "bazooka"){
- $moneyAll += 5600;
- }
- }
- $diff = $moneyAll - $moneyNiki;
- if($moneyAll >= $moneyNiki){
- printf("Not enough money! You need %s more money.", $diff);
- }else{
- printf("You bought all %.0f items! Get to work and defeat the bomb!\n", $numItems);
- }
Add Comment
Please, Sign In to add comment