ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1203. Scientific Conference

Test #7 why?
Posted by AlexRad 6 Apr 2015 14:29
Why my programm does not pass test #7 ?

Give me please that test!

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

using System.Globalization;
using System.Threading;

namespace _1203.Научная_конференция
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var n = int.Parse(Console.ReadLine().Trim());

            var reports = new List<Tuple<int, int>>(n);
            for(var i = 0; i < n; i++)
            {
                var tokens = Console.ReadLine().Trim().
                    Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                reports.Add(Tuple.Create(int.Parse(tokens[0]), int.Parse(tokens[1])));
            }

            reports.Sort();

            var weights = new int[n];
            var weight = -1;

            var reportStartComparer = new ReportStartComparer();
            for (var i = 0; i < n; i++)
            {
                if (weights[i] > weight)
                    weight = weights[i];

                var nextReport = Tuple.Create(reports[i].Item2 + 1, 0);
                var idx = reports.BinarySearch(nextReport, reportStartComparer);
                if (idx < 0)
                    idx = ~idx;
                if (idx < n && weights[idx] < weight + 1)
                    weights[idx] = weight + 1;
            }

            Console.WriteLine(weight + 1);
        }
    }

    class ReportStartComparer: IComparer<Tuple<int, int>>
    {
        public int Compare(Tuple<int, int> x, Tuple<int, int> y)
        {
            return x.Item1 - y.Item1;
        }
    }
}