47312023-03-31 10:22:30Leventusz19Váltakozó (75 pont)csharpWrong answer 27/75587ms70876 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(a.Max() > n / 2 + 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
base27/75
1Wrong answer0/028ms21172 KiB
2Wrong answer0/028ms23972 KiB
3Partially correct2/328ms21984 KiB
4Accepted3/327ms22220 KiB
5Partially correct2/327ms22416 KiB
6Accepted3/328ms22888 KiB
7Accepted3/3421ms70876 KiB
8Time limit exceeded0/3580ms31368 KiB
9Accepted3/330ms24832 KiB
10Accepted3/330ms24548 KiB
11Partially correct2/334ms31848 KiB
12Partially correct2/334ms32088 KiB
13Partially correct2/334ms32008 KiB
14Partially correct2/334ms32140 KiB
15Time limit exceeded0/3586ms31876 KiB
16Time limit exceeded0/3563ms31944 KiB
17Time limit exceeded0/3575ms31824 KiB
18Time limit exceeded0/3587ms31660 KiB
19Time limit exceeded0/3574ms31664 KiB
20Time limit exceeded0/3587ms32164 KiB
21Time limit exceeded0/3573ms32016 KiB
22Time limit exceeded0/6583ms33768 KiB
23Time limit exceeded0/6572ms32616 KiB
24Time limit exceeded0/6572ms32780 KiB