이전 값 보다 커지는 수, 이전 값 보다 작아지는 수를 각각 구해서 각 카운트를 출력하는 문제.
해결방법.
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
class Solution
{
// Complete the breakingRecords function below.
static int[] breakingRecords(int[] scores)
{
int max = scores[0]; // 스코어 0번의 값으로 초기화
int min = scores[0];
int[] count = new int[2]; // 출력할 min값 max의 값
for (int i = 1; i < scores.Length; i++)
{
if (scores[i] > max) // 받아둔 max값보다 크면
{
max = scores[i];
count[0] += 1; // max 카운트 증가
}
if (scores[i] < min) // 받아둔 min값보다 작으면
{
min = scores[i];
count[1] += 1; // min 카운트 증가
}
}
return count;
}
static void Main(string[] args)
{
TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
int n = Convert.ToInt32(Console.ReadLine());
int[] scores = Array.ConvertAll(Console.ReadLine().Split(' '), scoresTemp => Convert.ToInt32(scoresTemp));
int[] result = breakingRecords(scores);
textWriter.WriteLine(string.Join(" ", result));
textWriter.Flush();
textWriter.Close();
}
}