-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlights.cpp
More file actions
67 lines (59 loc) · 1.27 KB
/
lights.cpp
File metadata and controls
67 lines (59 loc) · 1.27 KB
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
/***
* n*m的网格 给定位置和开灯关灯的时间
* 问哪个时刻的灯开的最多
* 排序 遍历一遍 记录最大值
* **/
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>
using namespace std;
const int MAXN = 555;
const int MAXK = 1e5+1;
int n, m, k;
int cnt[MAXN][MAXN];
int tag[MAXN][MAXN];
struct engineer
{
int x, y, z;
int HH, MM;
double SS;
}eng[MAXK];
bool cmp(const engineer &A, const engineer &B)
{
if (A.HH != B.HH)
return A.HH < B.HH;
else if (A.MM != B.MM)
return A.MM < B.MM;
else
return A.SS < B.SS;
}
int main()
{
cin >> n >> m >> k;
for (int i = 0; i < k; i++)
{
cin >> eng[i].x >> eng[i].y >> eng[i].z ;
scanf("%d:%d:%lf", &eng[i].HH, &eng[i].MM, &eng[i].SS);
}
sort(eng, eng+k, cmp);
int c = 0, ans = 0;
for (int i = 0; i < k; i++)
{
if (eng[i].z)
cnt[eng[i].x][eng[i].y]--;
else
cnt[eng[i].x][eng[i].y]++;
if (cnt[eng[i].x][eng[i].y] == 0)
c--;
else if (cnt[eng[i].x][eng[i].y] == 1)
{
c++;
if (c >= ans)
{
ans = c;
memcpy(tag, cnt, sizeof(cnt));
}
}
}
}