×

# KETFAST editorial

Author: Chandan Boruah
Tester: Chandan Boruah
Editorialist: Chandan Boruah

CAKEWALK

Sorting.

# PROBLEM:

Given a word and time needed to type each english alphabet and the count of letters that can be skipped, print how long does it take to print the word. Note that you can skip exact count of letters and not skip all letters that are same and count once. Example, for 'aaa' you can skip 1 'a' for 1 letter and not all the 'a's. (Quotes for clarity).

Sort the alphabets in descending order by time needed and then skip as many letters as given. Then sum rest of the letters in the word.

# EXPLANATION:

Sort the alphabets in descending order by time needed and then skip as many letters as given so that you can skip the letters that time larger times. All you will be left with is the letters that take lesser (or equal time in some cases), then print the sum of those times.

# AUTHOR'S AND TESTER'S SOLUTIONS:

using System;
using System.Collections.Generic;
class some
{
public static void Main()
{
char[]let="abcdefghijklmnopqrstuvwxyz".ToCharArray();
for(int t=0;t<n;t++)
{
int[]c=new int[word.Length];
for(int i=0;i<c.Length;i++)
{
c[i]=Int32.Parse(ss[Array.IndexOf(let,word[i])]);
}
Array.Sort(c);
Array.Reverse(c);
int sum=0;int ret=0;
for(int i=0;i<c.Length;i++)
{
if(sum>=rem)ret+=c[i];
sum++;
}
Console.WriteLine(ret);
}
}
}


13310
accept rate: 0%

19.6k349497539

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,182
×770
×170
×4
×2

question asked: 06 Oct '16, 09:49

question was seen: 641 times

last updated: 06 Oct '16, 12:21