47332023-03-31 10:25:57Leventusz19Váltakozó (75 pont)csharpWrong answer 24/75586ms32672 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[(int)x-'a']++;
            if(2 * a.Max() > n + 1){Console.WriteLine("-1"); return;}
            for(char last='-'; n>=0; n--){
                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;
                    }
                }
            }
            Console.WriteLine(o); ;
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base24/75
1Wrong answer0/028ms20896 KiB
2Wrong answer0/028ms23692 KiB
3Partially correct2/328ms21768 KiB
4Accepted3/327ms21616 KiB
5Partially correct2/328ms21704 KiB
6Accepted3/328ms22176 KiB
7Wrong answer0/327ms22012 KiB
8Wrong answer0/329ms23192 KiB
9Accepted3/329ms23624 KiB
10Accepted3/329ms23472 KiB
11Partially correct2/334ms30832 KiB
12Partially correct2/332ms31308 KiB
13Partially correct2/334ms31844 KiB
14Partially correct2/332ms32388 KiB
15Time limit exceeded0/3586ms32128 KiB
16Time limit exceeded0/3574ms31872 KiB
17Time limit exceeded0/3574ms32032 KiB
18Time limit exceeded0/3569ms32336 KiB
19Time limit exceeded0/3570ms32412 KiB
20Time limit exceeded0/3578ms32316 KiB
21Time limit exceeded0/3572ms32532 KiB
22Time limit exceeded0/6554ms32672 KiB
23Time limit exceeded0/6563ms32612 KiB
24Time limit exceeded0/6564ms32520 KiB