-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEISCORING.cs
88 lines (78 loc) · 2.43 KB
/
EISCORING.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EISCORING
{
public class Program
{
public static int p = 0;
public static void Main(string[] args)
{
var n = NextInt();
var m = NextInt();
p = NextInt();
var list = new Student[n];
for (int i = 0; i < n; i++)
{
list[i] = new Student(i+1);
list[i].score = new int[p];
}
while (m-- > 0)
{
var id = NextInt()-1;
list[id].addScore(NextInt()-1, NextInt());
}
Array.Sort(list);
StringBuilder result = new StringBuilder();
for (int i = 0; i < n; i++)
{
var stu = list[i];
result.Append(stu.id + " " + stu.total);
foreach (var item in stu.score)
{
result.Append(" "+item);
}
result.Append("\n");
}
Console.Write(result);
}
class Student : IComparable<Student>
{
public int id = 0;
public int[] score;
public int total = 0;
public Student(int id)
{
this.id = id;
}
public void addScore(int index, int value)
{
var tmp = value - score[index];
score[index] = score[index] < value ? value : score[index];
total += tmp > 0 ? tmp : 0;
}
public int CompareTo(Student other)
{
var tmp = other.total - this.total;
return tmp == 0?this.id.CompareTo(other.id):tmp ;
}
}
static int s_index = 0;
static List<string> s_tokens;
private static string Next()
{
while (s_tokens == null || s_index == s_tokens.Count())
{
s_tokens = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
s_index = 0;
}
return s_tokens[s_index++];
}
private static int NextInt()
{
return Int32.Parse(Next());
}
}
}