Submission #2530854
Source Code Expand
#include <cstdio> #include <iostream> #include <string.h> #include <string> #include <map> #include <queue> #include <deque> #include <vector> #include <set> #include <algorithm> #include <math.h> #include <cmath> #include <stack> #include <iomanip> #define mem0(a) memset(a,0,sizeof(a)) #define meminf(a) memset(a,0x3f,sizeof(a)) using namespace std; typedef long long ll; typedef long double ld; typedef double db; const int maxn=200005,inf=0x3f3f3f3f; const ll llinf=0x3f3f3f3f3f3f3f3f; const ld pi=acos(-1.0L); vector<int> v[maxn]; int main() { int n,m,i,j,l,r; scanf("%d%d",&n,&m); priority_queue<int,vector<int>,greater<int> > pq; for (i=1;i<=n;i++) { scanf("%d%d",&l,&r); if (l==0) pq.push(r); else v[l].push_back(r); } for (i=1;i<=m+1;i++) { sort(v[i].begin(),v[i].end()); } int pos=-1; for (i=1;i<=m;i++) { //枚举左界 if (v[i].size()>1) { //当前左界有多个人,则只坐右界最大的那个人 for (j=0;j<v[i].size()-1;j++) pq.push(v[i][j]); } else if (v[i].size()==0) { //当前左界无人 pos=max(pos,i); while (!v[pos].size()&&pos<=m) pos++; if (v[pos].size()) v[pos].pop_back(); else if (!pq.empty()) if (pq.top()<=i) pq.pop(); } } int ans=pq.size(); printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Exhausted? |
User | AliceZero |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1589 Byte |
Status | AC |
Exec Time | 72 ms |
Memory | 8960 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:28:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&m); ^ ./Main.cpp:31:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&l,&r); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 56 ms | 8444 KB |
02.txt | AC | 36 ms | 7424 KB |
03.txt | AC | 65 ms | 8832 KB |
04.txt | AC | 64 ms | 8832 KB |
05.txt | AC | 5 ms | 5120 KB |
06.txt | AC | 47 ms | 7936 KB |
07.txt | AC | 60 ms | 8312 KB |
08.txt | AC | 65 ms | 8960 KB |
09.txt | AC | 57 ms | 7932 KB |
10.txt | AC | 19 ms | 6272 KB |
11.txt | AC | 45 ms | 7168 KB |
12.txt | AC | 34 ms | 7164 KB |
13.txt | AC | 43 ms | 7164 KB |
14.txt | AC | 43 ms | 7164 KB |
15.txt | AC | 45 ms | 7168 KB |
16.txt | AC | 38 ms | 7168 KB |
17.txt | AC | 65 ms | 8700 KB |
18.txt | AC | 72 ms | 8700 KB |
19.txt | AC | 61 ms | 8316 KB |
20.txt | AC | 67 ms | 8696 KB |
21.txt | AC | 15 ms | 5760 KB |
22.txt | AC | 64 ms | 8700 KB |
23.txt | AC | 12 ms | 5504 KB |
24.txt | AC | 66 ms | 8700 KB |
25.txt | AC | 27 ms | 6136 KB |
26.txt | AC | 25 ms | 6136 KB |
27.txt | AC | 34 ms | 6136 KB |
28.txt | AC | 33 ms | 6136 KB |
29.txt | AC | 41 ms | 6136 KB |
30.txt | AC | 42 ms | 6136 KB |
31.txt | AC | 71 ms | 8700 KB |
32.txt | AC | 56 ms | 8320 KB |
33.txt | AC | 64 ms | 8700 KB |
34.txt | AC | 42 ms | 7296 KB |
35.txt | AC | 33 ms | 6912 KB |
36.txt | AC | 65 ms | 8700 KB |
37.txt | AC | 3 ms | 4992 KB |
38.txt | AC | 3 ms | 4992 KB |
39.txt | AC | 3 ms | 4992 KB |
40.txt | AC | 3 ms | 4864 KB |
41.txt | AC | 3 ms | 4864 KB |
42.txt | AC | 3 ms | 4864 KB |
43.txt | AC | 4 ms | 4992 KB |
44.txt | AC | 3 ms | 4992 KB |
s1.txt | AC | 3 ms | 4864 KB |
s2.txt | AC | 3 ms | 4992 KB |
s3.txt | AC | 3 ms | 4992 KB |
s4.txt | AC | 3 ms | 4864 KB |