- #1
SlurrerOfSpeech
- 141
- 11
Any idea where I'm going wrong here? It's failing some test cases. I thought my solution was straightforward (if not brute force).
Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
static void Main(String[] args)
{
int k = Int32.Parse(Console.ReadLine().Split(' ')[1]);
var S = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
int max = Int32.MinValue;
foreach(int i in S)
{
var ss = new List<int>() { i };
foreach(int j in S.Skip(i))
if(ss.All(m => (m + j) % k != 0))
ss.Add(j);
if(ss.Count > max)
max = ss.Count;
}
Console.WriteLine(max);
}
}
Last edited by a moderator: