코딩테스트

06/02 백준 코딩테스트 11399 ATM

박준희 2021. 6. 2. 23:31
728x90

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> vs = new List<int>();
            int n = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();
            string[] p = input.Split(' ');
            Array.Sort(p);
            for (int i = 0; i<n; i++)
            {
                vs.Add(int.Parse(p[i]));
            }
            vs.Sort();
            int sum = vs[0];
            int tmp = vs[0];
            for (int i = 1; i < n; i++)
            {
                tmp += vs[i];
                sum += tmp;
            }
            Console.WriteLine(sum);

        }
    }
}

 

결과는 제대로 나오는데 틀렸다고 떠서 방법을 바꿔서 시도했다.

작성하는데 1시간 정도 걸린 것 같다.

728x90