Rezultati

Up. imeNalogaJezikRezultatČas oddaje
CryADsisAM Akcija C# 100/100OK 20. apr '17 @ 19:45

Test Točke Porabljen spomin Porabljen čas Status
#1 7/7 23,035 MiB 0,000 s OK
#2 7/7 20,996 MiB 0,000 s OK
#3 7/7 20,992 MiB 0,000 s OK
#4 7/7 21,039 MiB 0,000 s OK
#5 8/8 28,234 MiB 0,000 s OK
#6 8/8 25,961 MiB 0,000 s OK
#7 8/8 28,168 MiB 0,000 s OK
#8 8/8 28,168 MiB 0,000 s OK
#9 8/8 24,180 MiB 0,000 s OK
#10 8/8 26,176 MiB 0,000 s OK
#11 8/8 24,176 MiB 0,000 s OK
#12 8/8 24,195 MiB 0,000 s OK
#13 8/8 20,805 MiB 0,000 s OK

Ocenjevani program (Program.cs):
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sale
{
    public class MData
    {
        public string Name { get; set; }
        public int MaxDays { get; set; }
        public int MaxDaysToMonth { get; set; }
        public int MonthNum { get; set; }
    }

    public class Date
    {
        static List<MData> mesci = new List<MData>()
        {
            new MData() { Name = "januar", MaxDays = 31, MonthNum = 1, MaxDaysToMonth = 0 },
            new MData() { Name = "februar", MaxDays = 28, MonthNum = 2, MaxDaysToMonth = 31 },
            new MData() { Name = "marec", MaxDays = 31, MonthNum = 3, MaxDaysToMonth = 59 },
            new MData() { Name = "april", MaxDays = 30, MonthNum = 4, MaxDaysToMonth = 90 },
            new MData() { Name = "maj", MaxDays = 31, MonthNum = 5, MaxDaysToMonth = 120 },
            new MData() { Name = "junij", MaxDays = 30, MonthNum = 6, MaxDaysToMonth = 151 },
            new MData() { Name = "julij", MaxDays = 31, MonthNum = 7, MaxDaysToMonth = 181 },
            new MData() { Name = "avgust", MaxDays = 31, MonthNum = 8, MaxDaysToMonth = 212 },
            new MData() { Name = "september", MaxDays = 30, MonthNum = 9, MaxDaysToMonth = 243 },
            new MData() { Name = "oktober", MaxDays = 31, MonthNum = 10, MaxDaysToMonth = 273 },
            new MData() { Name = "november", MaxDays = 30, MonthNum = 11, MaxDaysToMonth = 304 },
            new MData() { Name = "december", MaxDays = 31, MonthNum = 12, MaxDaysToMonth = 334 }
        };

        public int day { get; set; }
        public string month { get; set; }

        public int Subtract(Date d2)
        {
            Date d1 = this;
            var m1 = mesci.Find(x => x.Name == d1.month);
            var m2 = mesci.Find(x => x.Name == d2.month); 

            return (m1.MaxDaysToMonth + d1.day) - (m2.MaxDaysToMonth + d2.day);
        }
    }

    public class Produkt
    {
        public static Date current = new Date() { day = 20, month = "april" };
        public decimal AverageDaily { get; set; }
        public int Stock { get; set; }
        public Date ExpiryDate { get; set; }

        public string WhatAction()
        {
            int subt = ExpiryDate.Subtract(current);
            if (subt < 0) return "V SMETI";  // ce so potekli - V SMETI
            if (subt == 0 && AverageDaily > Stock) return "OK";  // ce potece ta dan, ampak je AVG vecji od zaloge - OK

            if ((subt + 1) * AverageDaily < Stock) return "AKCIJA";   // ce je AVG premali, da bi prodali zalogo - AKCIJA
            else return "OK";
        }
    }

    class Program
    {      
        static void Main(string[] args)
        {
            var clt = new CultureInfo("si");
            List<Produkt> prds = new List<Produkt>();
            int N = int.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                string l = Console.ReadLine();
                var sp = l.Split(' ');
                int stock = int.Parse(sp[0]);
                var avg = decimal.Parse(sp[1], clt);
                string dateraw = l.Substring(sp[0].Length + sp[1].Length + 2);

                int indpika = dateraw.IndexOf('.');
                var monthd = dateraw.Split(' ');
                Date dt = new Date()
                {
                    day = int.Parse(dateraw.Substring(0, indpika)),
                    month = monthd[1]
                };

                prds.Add(new Produkt()
                {
                    AverageDaily = avg,
                    ExpiryDate = dt,
                    Stock = stock
                });
            }

            using (var writer = new StreamWriter(Console.OpenStandardOutput()))
            {
                for (int i = 0; i < prds.Count; i++)
                {
                    writer.Write(prds[i].WhatAction() + ((i == prds.Count - 1) ? "" : "\n"));
                }
            }
        }
    }
}