47222023-03-31 10:01:42TortelliniJrVáltakozó (75 pont)csharpWrong answer 21/75560ms34040 KiB
using System;
using System.Linq;
namespace Valtakozz
{

    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int[] cnt = new int[26];

            foreach (char c in s)
            {
                cnt[c - 'a']++;
            }

            int n = s.Length, mx = cnt.Max();
            char last = '-';

            if (2 * mx > n + 1)
            {
                Console.WriteLine("-1");
                return;
            }
            char current;
            for (int i = n; i > 0;)
            {
                mx = cnt.Max();
                for (int u = 0; u < 26; u++)
                {
                    current = (char)(u + 'a');
                    if (last != current && cnt[u] > 0 && (2 * mx <= n || mx == cnt[u]))
                    {
                        Console.Write(last = current);
                        cnt[u]--;
                        break;
                    }
                }
                i--;
            }

            Console.WriteLine();
        }
    }

}
SubtaskSumTestVerdictTimeMemory
base21/75
1Wrong answer0/027ms20564 KiB
2Wrong answer0/028ms21104 KiB
3Accepted3/326ms21580 KiB
4Accepted3/326ms21880 KiB
5Accepted3/328ms21968 KiB
6Accepted3/327ms21892 KiB
7Accepted3/374ms23236 KiB
8Time limit exceeded0/3500ms31604 KiB
9Accepted3/329ms23744 KiB
10Accepted3/329ms24092 KiB
11Wrong answer0/332ms23136 KiB
12Wrong answer0/332ms22960 KiB
13Wrong answer0/332ms23328 KiB
14Wrong answer0/332ms23260 KiB
15Time limit exceeded0/3560ms32880 KiB
16Time limit exceeded0/3535ms11960 KiB
17Wrong answer0/3465ms33132 KiB
18Wrong answer0/3458ms33288 KiB
19Time limit exceeded0/3554ms33164 KiB
20Time limit exceeded0/3554ms33200 KiB
21Wrong answer0/3442ms33404 KiB
22Wrong answer0/6486ms33864 KiB
23Time limit exceeded0/6555ms12988 KiB
24Wrong answer0/6379ms34040 KiB