Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: us-ascii
Méret: 1 KB
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Utemezes
{
class Job : IComparable<Job>
{
public int start, end;
public int id;
public int CompareTo(Job other)
{
if (this.end < other.end) return -1;
else
if (this.end > other.end) return 1;
else
return 0;
}
public Job( int _start, int _end, int _id )
{
start = _start;
end = _end;
id = _id;
}
}
class Program
{
private int n;
private List<Job> jobs;
public Program()
{
StreamReader ins = new StreamReader("utemez.be7");
StreamWriter outs = new StreamWriter("utemez.ki7");
string[] line = ins.ReadLine().Split(' ');
n = int.Parse( line[0] );
jobs = new List<Job>(n);
int id = 1;
for (int i = 0; i < n; i++)
{
line = ins.ReadLine().Split(' ');
jobs.Add(new Job(int.Parse(line[0]), int.Parse(line[1]), id++));
}
jobs.Sort();
List<int> solutions = new List<int>(n);
int lastEnd = -1;
for (int i = 0; i < n; i++)
{
if (jobs[i].start > lastEnd)
{
solutions.Add(jobs[i].id);
lastEnd = jobs[i].end;
}
}
outs.WriteLine( solutions.Count );
for (int i = 0; i < solutions.Count; i++)
{
outs.Write( "{0} ", solutions[i] );
}
outs.WriteLine();
outs.Close();
}
static void Main(string[] args)
{
new Program();
}
}
}