93602024-02-21 09:35:38Leventusz09Váltakozó (75 pont)csharpWrong answer 12/75592ms70416 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Váltakozó{
    class Program{
        static void Main(){
            string str = Console.ReadLine();
            int N = str.Length;
            int[] C = new int[26];
            int e = 0, l = 0;
            foreach (int i in str) C[i - 97]++;

            string o1 = "";
            for (int i=0, last = -1; l != N; i++){
                if (i > 25) for(int j=l-1; l!= N && j>0; j--){
                    if(o1[j] != C.Max() && o1[j-1] != C.Max()){
                            o1 = o1.Substring(0, j) + (char)(C.Max()+97) + o1.Substring(j);
                            C[Array.IndexOf(C, C.Max())]--;
                            l++;
                    }
                }else
                if(C[i] > 0 && last != i){
                    C[i]--;
                    l++;
                    o1 += (char)(i + 97);
                    last = i;
                    i = e - 1;
                }else{
                    
                }
            }
            Console.WriteLine(o1);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base12/75
1Wrong answer0/028ms21084 KiB
2Wrong answer0/030ms23708 KiB
3Accepted3/327ms21548 KiB
4Accepted3/326ms21796 KiB
5Accepted3/326ms22020 KiB
6Accepted3/327ms22288 KiB
7Wrong answer0/3356ms70416 KiB
8Time limit exceeded0/3584ms30568 KiB
9Time limit exceeded0/3592ms30716 KiB
10Time limit exceeded0/3552ms31352 KiB
11Wrong answer0/334ms31652 KiB
12Wrong answer0/335ms31716 KiB
13Wrong answer0/334ms32044 KiB
14Wrong answer0/334ms32252 KiB
15Time limit exceeded0/3559ms32196 KiB
16Time limit exceeded0/3577ms31920 KiB
17Time limit exceeded0/3589ms32168 KiB
18Time limit exceeded0/3582ms32372 KiB
19Time limit exceeded0/3551ms32092 KiB
20Time limit exceeded0/3573ms32376 KiB
21Time limit exceeded0/3560ms32360 KiB
22Time limit exceeded0/6580ms32304 KiB
23Time limit exceeded0/6574ms32568 KiB
24Time limit exceeded0/6578ms32424 KiB