Skip to content

Instantly share code, notes, and snippets.

@oyakodon
Created March 28, 2016 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oyakodon/ce3156cce4d077a73cd2 to your computer and use it in GitHub Desktop.
Save oyakodon/ce3156cce4d077a73cd2 to your computer and use it in GitHub Desktop.
ARC045のB問題(未完成)です。 / C#
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
var l = ReadInt();
var N = l[0];
var M = l[1];
var s = new List<int>();
var t = new List<int>();
var imos = new int[N + 2];
var x = new List<int>();
for (var i = 0; i < M; ++i )
{
var l2 = ReadInt();
s.Add(l2[0]);
t.Add(l2[1]);
imos[l2[0]]++;
imos[l2[1] + 1]--;
}
for(var i = 1; i < N + 2; i++ )
{
imos[i] += imos[i - 1];
}
for (var i = 0; i < M; ++i )
{
x.Add(i);
for (var j = s[i]; j <= t[i]; j++ )
{
if (imos[j] - 1 < 1 )
{
x.Remove(i);
break;
}
}
}
Console.WriteLine(x.Count);
foreach(var i in x )
{
Console.WriteLine(i + 1);
}
}
static List<int> ReadInt ()
{
var input = Console.ReadLine();
var ret = new List<int>();
foreach (var numstr in input.Split() )
{
ret.Add(int.Parse(numstr));
}
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment