Algorithm
[BOJ/C#] 10162 전자레인지
일등하이
2023. 1. 31. 12:57
반응형
https://www.acmicpc.net/problem/10162
10162번: 전자레인지
3개의 시간조절용 버튼 A B C가 달린 전자레인지가 있다. 각 버튼마다 일정한 시간이 지정되어 있어 해당 버튼을 한번 누를 때마다 그 시간이 동작시간에 더해진다. 버튼 A, B, C에 지정된 시간은
www.acmicpc.net
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
namespace BOJ
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
StreamWriter sw = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
//분 -> 초
//300, 60, 10;
int[] arr = new int[3];
int t = int.Parse(sr.ReadLine());
bool failed = false;
while (t > 0)
{
if (t >= 300)
{
t -= 300;
arr[0]++;
}
else if (t < 300 && t >= 60)
{
t -= 60;
arr[1]++;
}
else if (t < 60 && t >= 10)
{
t -= 10;
arr[2]++;
}
else
{
failed = true;
break;
}
}
if (failed)
{
sw.WriteLine(-1);
}
else
{
for (int i = 0; i < arr.Length; i++)
{
sw.Write("{0} ", arr[i]);
}
}
sr.Close();
sw.Close();
}
}
}
반응형