Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14기 손서희]C# 기초 세션 1차시 과제 제출 #111

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/Project2/v16/.suo
Binary file not shown.
47 changes: 47 additions & 0 deletions king_assignment_cs1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project2
{
class king_assignment_cs1
{
static int n, k;
static int[] num = new int[1000001];

static int GetMax(List<int> arr, int l, int r)
{
int cnt = 0;
while (r < n)
{
if (num[arr[r]] != k)
{
num[arr[r]]++;
r++;
}
else
{
num[arr[l]]--;
l++;
}
cnt = Math.Max(cnt, r - l);
}
return cnt;
}

static void Main()
{
var input = Console.ReadLine().Split(' ');
n = int.Parse(input[0]);
k = int.Parse(input[1]);

List<int> arr = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

int maxCnt = GetMax(arr, 0, 0);

Console.WriteLine(maxCnt);
}
}
}
File renamed without changes.
Binary file added 지난 과제/assignment1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 지난 과제/캡처.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.