怎么申请建立个人免费网站,深圳优化网站方法,常宁市城市建设规划管理局网站,盗网站后台源码https://vjudge.net/problem/POJ-3190 cin和scanf差这么多么。。tle和300ms 思路#xff1a;先对结构体x升序y升序#xff0c;再对优先队列重载#xff0c;按y升序。 然后依次入队#xff0c;如果node[i].xq.top().y ans#xff0c; 否则出队#xff0c;入队先对结构体x升序y升序再对优先队列重载按y升序。 然后依次入队如果node[i].xq.top().y ans 否则出队入队使用出队的那个摊位。 1 #includeiostream2 #includecstdio3 #includequeue4 #includecstring5 #includealgorithm6 #includecmath7 #includeset8 #define INF 0x3f3f3f3f9 typedef long long ll;
10 using namespace std;
11 struct Node{
12 int x, y;
13 int id;
14 bool operator(const Node a)const{
15 return y a.y;
16 }
17 }node[50010];
18 int n, maxm -INF, b[50010];
19 bool cmp(const Node a, const Node b)
20 {
21 if(a.x ! b.x)
22 return a.xb.x;
23 return a.yb.y;
24 }
25 int main()
26 {
27 scanf(%d, n);
28 int ans 1;
29 for(int i 0; i n; i){
30 scanf(%d%d, node[i].x, node[i].y);
31 node[i].idi1;
32 }
33 sort(node, noden, cmp);
34 priority_queueNode q;
35 q.push(node[0]);
36 b[node[0].id] ans;
37 for(int i 1; i n; i){
38 Node t q.top();
39 if(node[i].x t.y){
40 q.push(node[i]);
41 ans;
42 b[node[i].id] ans;
43 //maxm max(maxm, ans);
44 }
45 else if(node[i].x t.y){
46 q.pop();
47 q.push(node[i]);
48 b[node[i].id] b[t.id];
49 //cout b[t.id] t;
50 }
51 }
52 printf(%d\n, ans);
53 for(int i 1; i n; i){
54 printf(%d\n, b[i]);
55 }
56
57 return 0;
58 } 转载于:https://www.cnblogs.com/Surprisezang/p/9000363.html