Rezultati

Up. imeNalogaJezikRezultatČas oddaje
4c-2019 Ocenjevanje univerz C# 0/100Napačen odgovor (WA) 24. apr '19 @ 18:17

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 0/10 25,379 MiB 0,000 s Napačen odgovor
#2 [več] 0/10 25,527 MiB 0,000 s Napačen odgovor
#3 [več] 10/10 21,480 MiB 0,000 s OK
#4 [več] 0/10 25,492 MiB 0,000 s Napačen odgovor
#5 [več] 0/10 23,477 MiB 0,000 s Napačen odgovor
#6 [več] 0/10 23,516 MiB 0,000 s Napačen odgovor
#7 [več] 10/10 25,492 MiB 0,000 s OK
#8 [več] 10/10 23,484 MiB 0,000 s OK
#9 [več] 10/10 21,492 MiB 0,000 s OK
#10 [več] 10/10 25,523 MiB 0,000 s OK

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            double mya = 0, myb=0, a, b;
            double x = 0.5;
            double minX = 0, minY = 0;
            double y = 0.5;
            int n = Int32.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                List<string> s= Console.ReadLine().Split(' ').ToList();
                double counter = 0.5;
                if (i == 0)
                {
                    mya = Double.Parse(s[0]);
                    myb = Double.Parse(s[1]);
                }
                else
                {
                    a = Double.Parse(s[0]);
                    b = Double.Parse(s[1]);
                    if (mya >= a && myb >= b) continue;
                    if(mya < a && myb < b)
                    {
                        Console.WriteLine("Slabe metrike");
                        return;
                    }
                    if (mya * x + myb * y < a * x + b * y)
                    {
                        if (mya > a)
                        {
                            for(int j = 0; j < 20; j++)
                            {
                                if (mya * x + myb * y < a * x + b * y)
                                {
                                    x += counter;
                                    counter /= 2;
                                    y = 1 - x;
                                }
                                else if (mya * x + myb * y == a * x + b * y) break;
                                else
                                {
                                    x -= counter;
                                    counter /= 2;
                                    y = 1 - x;
                                }
                            }
                            if (minX > x||minY>y)
                            {
                                Console.WriteLine("Slabe metrike");
                                return;
                            }
                            minX = x;
                            minY = y;
                        }
                        else
                        {
                            for(int j = 0; j < 20; j++)
                            {
                                if (mya * x + myb * y < a * x + b * y)
                                {
                                    y += counter;
                                    counter /= 2;
                                    x = 1 - y;
                                }
                                else if (mya * x + myb * y == a * x + b * y) break;
                                else
                                {
                                    y -= counter;
                                    counter /= 2;
                                    x = 1 - y;
                                }
                            }
                            if (minY > y || minX > x)
                            {
                                Console.WriteLine("Slabe metrike");
                                return;
                            }
                            minX = x;
                            minY = y;
                        }                        
                    }

                }

            }
            Console.WriteLine(x + " " + y);
        }
    }
}