https://www.acmicpc.net/problem/2455
2455๋ฒ: ์ง๋ฅํ ๊ธฐ์ฐจ
์ต๊ทผ์ ๊ฐ๋ฐ๋ ์ง๋ฅํ ๊ธฐ์ฐจ๊ฐ 1๋ฒ์ญ(์ถ๋ฐ์ญ)๋ถํฐ 4๋ฒ์ญ(์ข ์ฐฉ์ญ)๊น์ง 4๊ฐ์ ์ ์ฐจ์ญ์ด ์๋ ๋ ธ์ ์์ ์ดํ๋๊ณ ์๋ค. ์ด ๊ธฐ์ฐจ์๋ ํ๊ฑฐ๋ ๋ด๋ฆฌ๋ ์ฌ๋ ์๋ฅผ ์๋์ผ๋ก ์ธ์ํ ์ ์๋ ์ฅ์น๊ฐ ์๋ค.
www.acmicpc.net
My Solution
using System;
using System.Linq;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int[] result = new int[5];
result[0] = 0;
for (int i = 1; i < 5; i++)
{
int[] n = Array.ConvertAll<string, int>(Console.ReadLine().Split(), int.Parse);
int input = n[1];
int output = n[0];
result[i] = result[i - 1] + input - output;
}
Console.WriteLine(result.Max());
}
}
}
Solution
- if(max<count) max = count๋ก ์ต๋๊ฐ ๊ฐฑ์ !! ๊ฐ๋จํ ์ํ,,
using static System.Console;
class Program
{
static void Main() {
int max = 0;
int count = 0;
for(int i=0; i<4; i++){
string[] r = ReadLine().Split(' ');
count = count - int.Parse(r[0]);
count = count + int.Parse(r[1]);
if (max < count)
max = count;
}
WriteLine(max);
}
}
'๐ฉโ๐ปProgramming > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C#][programmers] ๋ฌธ์์ด ๋ค์ง๊ธฐ (0) | 2022.11.10 |
---|---|
[C#] [BOJ#13063] Lobby (0) | 2022.08.14 |
[C#] [BOJ#5073] ์ผ๊ฐํ๊ณผ ์ธ ๋ณ (0) | 2022.08.14 |
[C#] [BOJ#2775] ๋ถ๋ ํ์ฅ์ด ๋ ํ ์ผ (0) | 2022.08.14 |
[C#] [BOJ#10872] ํฉํ ๋ฆฌ์ผ (0) | 2022.08.14 |
๋๊ธ