47362023-03-31 10:30:42Leventusz19Váltakozó (75 pont)csharpWrong answer 6/75592ms32380 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Váltakozó_szöveg{
    class Program{
        static void Main(){
            string in1 = Console.ReadLine();
            string o = "";
            int[] a = new int[26];
            int n = in1.Length - 1;
            int m;
            foreach (char x in in1) a[x-'a']++;
            if(2 * a.Max() > n + 1){Console.WriteLine("-1"); return;}
            for(char last='-'; n>=1;){
                m = a.Max();
                for(int i=0; i < 26; i++){
                    if (last != (char)(i + 'a') && a[i]>0 && (2 * m <= n || m == a[i])){
                        o += (last = (char)(i + 'a'));
                        a[i]--;
                        break;
                    }
                }
                n--;
            }
            Console.WriteLine(o);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base6/75
1Wrong answer0/027ms20680 KiB
2Wrong answer0/029ms23408 KiB
3Wrong answer0/327ms20852 KiB
4Wrong answer0/327ms21352 KiB
5Wrong answer0/328ms21972 KiB
6Wrong answer0/327ms22240 KiB
7Wrong answer0/327ms22224 KiB
8Wrong answer0/329ms23328 KiB
9Accepted3/328ms23252 KiB
10Accepted3/329ms23360 KiB
11Wrong answer0/334ms31124 KiB
12Wrong answer0/332ms31172 KiB
13Wrong answer0/332ms31300 KiB
14Wrong answer0/332ms31364 KiB
15Time limit exceeded0/3569ms30800 KiB
16Time limit exceeded0/3570ms30868 KiB
17Time limit exceeded0/3592ms31240 KiB
18Time limit exceeded0/3550ms31132 KiB
19Time limit exceeded0/3578ms31432 KiB
20Time limit exceeded0/3578ms31708 KiB
21Time limit exceeded0/3570ms31588 KiB
22Time limit exceeded0/6583ms31868 KiB
23Time limit exceeded0/6572ms32188 KiB
24Time limit exceeded0/6566ms32380 KiB