47352023-03-31 10:28:58Leventusz19Váltakozó (75 pont)csharpWrong answer 24/75588ms32460 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>=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);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base24/75
1Wrong answer0/027ms20944 KiB
2Wrong answer0/028ms23556 KiB
3Partially correct2/327ms21440 KiB
4Accepted3/327ms21804 KiB
5Partially correct2/327ms21964 KiB
6Accepted3/328ms22332 KiB
7Wrong answer0/327ms22384 KiB
8Wrong answer0/328ms23292 KiB
9Accepted3/329ms23312 KiB
10Accepted3/329ms23788 KiB
11Partially correct2/332ms31596 KiB
12Partially correct2/332ms31120 KiB
13Partially correct2/330ms31588 KiB
14Partially correct2/330ms31560 KiB
15Time limit exceeded0/3569ms31336 KiB
16Time limit exceeded0/3563ms31740 KiB
17Time limit exceeded0/3568ms32208 KiB
18Time limit exceeded0/3574ms32232 KiB
19Time limit exceeded0/3583ms31912 KiB
20Time limit exceeded0/3546ms32224 KiB
21Time limit exceeded0/3579ms32376 KiB
22Time limit exceeded0/6575ms32392 KiB
23Time limit exceeded0/6588ms32460 KiB
24Time limit exceeded0/6544ms32380 KiB