Advertisement
aryobarzan

Codeforces 40-B

Mar 28th, 2011
1,613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. namespace Iran
  3. {
  4.         class Amir
  5.         {
  6.                 public static void Main()
  7.                 {
  8.                         string[] input=Console.ReadLine().Split(' ');
  9.                         int n=int.Parse(input[0]);
  10.                         int b=int.Parse(input[1]);
  11.                         int maximum=b;
  12.                         string[] dollars=Console.ReadLine().Split(' ');
  13.                         for(int i=0;i<n;i++)
  14.                         {
  15.                         for(int j=i;j<n;j++)
  16.                         {
  17.                                 int canbuy=b/int.Parse(dollars[i]);
  18.                                 int more=b%int.Parse(dollars[i]);
  19.                                 int sell=canbuy*int.Parse(dollars[j])+more;
  20.                                 if(sell>maximum)
  21.                                                 maximum=sell;
  22.                         }
  23.                         }
  24.                         Console.WriteLine(maximum);
  25.                 }//end of main
  26.         }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement