# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
295079 |
2020-09-09T13:10:52 Z |
문홍윤(#5821) |
치료 계획 (JOI20_treatment) |
C++17 |
|
642 ms |
43352 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(all(x))
#define press(x) x.erase(unique(all(x)), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
int n, m;
bool ch[100010];
pair<pii, pil> arr[100010];
vector<int> id;
struct FENWICK{
vector<pli> tree[100010];
vector<int> sum(int i, LL lim){
vector<int> ret;
for(; i; i-=(i&-i)){
while(tree[i].size()){
pli nw=tree[i].back();
if(nw.F>lim)break;
ret.eb(nw.S);
tree[i].pop_back();
}
}
return ret;
}
void update(int i, pli num){
for(; i<=100000; i+=(i&-i))tree[i].eb(num);
}
}fen;
priority_queue<pli, vector<pli>, greater<pli> > pq;
bool cmp(pair<pii, pil> a, pair<pii, pil> b){
return a.F.F+a.F.S>b.F.F+b.F.S;
}
int main(){
scanf("%d %d", &n, &m);
for(int i=1; i<=m; i++){
scanf("%d %d %d %lld", &arr[i].F.F, &arr[i].F.S, &arr[i].S.F, &arr[i].S.S);
id.eb(arr[i].F.S-arr[i].F.F);
}
svec(id); press(id);
sort(arr+1, arr+m+1, cmp);
for(int i=1; i<=m; i++){
if(arr[i].F.S==1){
ch[i]=true;
pq.push(mp(arr[i].S.S, i));
}
int num=lower_bound(all(id), arr[i].F.S-arr[i].F.F)-id.begin()+1;
fen.update(num, mp(arr[i].F.F+arr[i].F.S, i));
}
while(pq.size()){
LL d=pq.top().F; int nw=pq.top().S;
pq.pop();
if(arr[nw].S.F==n)return !printf("%lld", d);
int num=upper_bound(all(id), arr[nw].S.F-arr[nw].F.F+1)-id.begin();
vector<int> vc=fen.sum(num, arr[nw].F.F+arr[nw].S.F+1);
for(auto i:vc){
ch[i]=true;
pq.push(mp(d+arr[i].S.S, i));
}
}
printf("-1");
}
Compilation message
treatment.cpp: In function 'int main()':
treatment.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
45 | scanf("%d %d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~
treatment.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
47 | scanf("%d %d %d %lld", &arr[i].F.F, &arr[i].F.S, &arr[i].S.F, &arr[i].S.S);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
282 ms |
26092 KB |
Output is correct |
2 |
Correct |
175 ms |
25068 KB |
Output is correct |
3 |
Correct |
444 ms |
37596 KB |
Output is correct |
4 |
Correct |
417 ms |
37692 KB |
Output is correct |
5 |
Correct |
121 ms |
36592 KB |
Output is correct |
6 |
Correct |
219 ms |
29636 KB |
Output is correct |
7 |
Correct |
366 ms |
30036 KB |
Output is correct |
8 |
Correct |
141 ms |
27828 KB |
Output is correct |
9 |
Correct |
101 ms |
26436 KB |
Output is correct |
10 |
Correct |
108 ms |
26580 KB |
Output is correct |
11 |
Correct |
133 ms |
24776 KB |
Output is correct |
12 |
Correct |
133 ms |
28008 KB |
Output is correct |
13 |
Correct |
282 ms |
39896 KB |
Output is correct |
14 |
Correct |
311 ms |
40152 KB |
Output is correct |
15 |
Correct |
382 ms |
25232 KB |
Output is correct |
16 |
Correct |
401 ms |
24924 KB |
Output is correct |
17 |
Correct |
347 ms |
25128 KB |
Output is correct |
18 |
Correct |
133 ms |
26572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2816 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Correct |
2 ms |
2688 KB |
Output is correct |
8 |
Correct |
2 ms |
2688 KB |
Output is correct |
9 |
Correct |
2 ms |
2688 KB |
Output is correct |
10 |
Correct |
3 ms |
2688 KB |
Output is correct |
11 |
Correct |
2 ms |
2688 KB |
Output is correct |
12 |
Correct |
2 ms |
2688 KB |
Output is correct |
13 |
Correct |
2 ms |
2688 KB |
Output is correct |
14 |
Correct |
2 ms |
2688 KB |
Output is correct |
15 |
Correct |
2 ms |
2688 KB |
Output is correct |
16 |
Correct |
2 ms |
2688 KB |
Output is correct |
17 |
Correct |
2 ms |
2688 KB |
Output is correct |
18 |
Correct |
2 ms |
2688 KB |
Output is correct |
19 |
Correct |
2 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2816 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Correct |
2 ms |
2688 KB |
Output is correct |
8 |
Correct |
2 ms |
2688 KB |
Output is correct |
9 |
Correct |
2 ms |
2688 KB |
Output is correct |
10 |
Correct |
3 ms |
2688 KB |
Output is correct |
11 |
Correct |
2 ms |
2688 KB |
Output is correct |
12 |
Correct |
2 ms |
2688 KB |
Output is correct |
13 |
Correct |
2 ms |
2688 KB |
Output is correct |
14 |
Correct |
2 ms |
2688 KB |
Output is correct |
15 |
Correct |
2 ms |
2688 KB |
Output is correct |
16 |
Correct |
2 ms |
2688 KB |
Output is correct |
17 |
Correct |
2 ms |
2688 KB |
Output is correct |
18 |
Correct |
2 ms |
2688 KB |
Output is correct |
19 |
Correct |
2 ms |
2688 KB |
Output is correct |
20 |
Correct |
14 ms |
4800 KB |
Output is correct |
21 |
Correct |
14 ms |
4800 KB |
Output is correct |
22 |
Correct |
12 ms |
4096 KB |
Output is correct |
23 |
Correct |
11 ms |
4096 KB |
Output is correct |
24 |
Correct |
10 ms |
4732 KB |
Output is correct |
25 |
Correct |
18 ms |
4096 KB |
Output is correct |
26 |
Correct |
16 ms |
4096 KB |
Output is correct |
27 |
Correct |
15 ms |
4224 KB |
Output is correct |
28 |
Correct |
11 ms |
4800 KB |
Output is correct |
29 |
Correct |
17 ms |
4096 KB |
Output is correct |
30 |
Correct |
9 ms |
4096 KB |
Output is correct |
31 |
Correct |
10 ms |
4096 KB |
Output is correct |
32 |
Correct |
10 ms |
4352 KB |
Output is correct |
33 |
Correct |
9 ms |
4224 KB |
Output is correct |
34 |
Correct |
15 ms |
4224 KB |
Output is correct |
35 |
Correct |
9 ms |
4224 KB |
Output is correct |
36 |
Correct |
9 ms |
4224 KB |
Output is correct |
37 |
Correct |
16 ms |
4224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
282 ms |
26092 KB |
Output is correct |
2 |
Correct |
175 ms |
25068 KB |
Output is correct |
3 |
Correct |
444 ms |
37596 KB |
Output is correct |
4 |
Correct |
417 ms |
37692 KB |
Output is correct |
5 |
Correct |
121 ms |
36592 KB |
Output is correct |
6 |
Correct |
219 ms |
29636 KB |
Output is correct |
7 |
Correct |
366 ms |
30036 KB |
Output is correct |
8 |
Correct |
141 ms |
27828 KB |
Output is correct |
9 |
Correct |
101 ms |
26436 KB |
Output is correct |
10 |
Correct |
108 ms |
26580 KB |
Output is correct |
11 |
Correct |
133 ms |
24776 KB |
Output is correct |
12 |
Correct |
133 ms |
28008 KB |
Output is correct |
13 |
Correct |
282 ms |
39896 KB |
Output is correct |
14 |
Correct |
311 ms |
40152 KB |
Output is correct |
15 |
Correct |
382 ms |
25232 KB |
Output is correct |
16 |
Correct |
401 ms |
24924 KB |
Output is correct |
17 |
Correct |
347 ms |
25128 KB |
Output is correct |
18 |
Correct |
133 ms |
26572 KB |
Output is correct |
19 |
Correct |
2 ms |
2688 KB |
Output is correct |
20 |
Correct |
2 ms |
2688 KB |
Output is correct |
21 |
Correct |
2 ms |
2688 KB |
Output is correct |
22 |
Correct |
2 ms |
2816 KB |
Output is correct |
23 |
Correct |
2 ms |
2688 KB |
Output is correct |
24 |
Correct |
2 ms |
2688 KB |
Output is correct |
25 |
Correct |
2 ms |
2688 KB |
Output is correct |
26 |
Correct |
2 ms |
2688 KB |
Output is correct |
27 |
Correct |
2 ms |
2688 KB |
Output is correct |
28 |
Correct |
3 ms |
2688 KB |
Output is correct |
29 |
Correct |
2 ms |
2688 KB |
Output is correct |
30 |
Correct |
2 ms |
2688 KB |
Output is correct |
31 |
Correct |
2 ms |
2688 KB |
Output is correct |
32 |
Correct |
2 ms |
2688 KB |
Output is correct |
33 |
Correct |
2 ms |
2688 KB |
Output is correct |
34 |
Correct |
2 ms |
2688 KB |
Output is correct |
35 |
Correct |
2 ms |
2688 KB |
Output is correct |
36 |
Correct |
2 ms |
2688 KB |
Output is correct |
37 |
Correct |
2 ms |
2688 KB |
Output is correct |
38 |
Correct |
14 ms |
4800 KB |
Output is correct |
39 |
Correct |
14 ms |
4800 KB |
Output is correct |
40 |
Correct |
12 ms |
4096 KB |
Output is correct |
41 |
Correct |
11 ms |
4096 KB |
Output is correct |
42 |
Correct |
10 ms |
4732 KB |
Output is correct |
43 |
Correct |
18 ms |
4096 KB |
Output is correct |
44 |
Correct |
16 ms |
4096 KB |
Output is correct |
45 |
Correct |
15 ms |
4224 KB |
Output is correct |
46 |
Correct |
11 ms |
4800 KB |
Output is correct |
47 |
Correct |
17 ms |
4096 KB |
Output is correct |
48 |
Correct |
9 ms |
4096 KB |
Output is correct |
49 |
Correct |
10 ms |
4096 KB |
Output is correct |
50 |
Correct |
10 ms |
4352 KB |
Output is correct |
51 |
Correct |
9 ms |
4224 KB |
Output is correct |
52 |
Correct |
15 ms |
4224 KB |
Output is correct |
53 |
Correct |
9 ms |
4224 KB |
Output is correct |
54 |
Correct |
9 ms |
4224 KB |
Output is correct |
55 |
Correct |
16 ms |
4224 KB |
Output is correct |
56 |
Correct |
339 ms |
43232 KB |
Output is correct |
57 |
Correct |
241 ms |
29288 KB |
Output is correct |
58 |
Correct |
270 ms |
26596 KB |
Output is correct |
59 |
Correct |
268 ms |
27112 KB |
Output is correct |
60 |
Correct |
229 ms |
24424 KB |
Output is correct |
61 |
Correct |
264 ms |
26596 KB |
Output is correct |
62 |
Correct |
331 ms |
43104 KB |
Output is correct |
63 |
Correct |
157 ms |
24172 KB |
Output is correct |
64 |
Correct |
150 ms |
24040 KB |
Output is correct |
65 |
Correct |
267 ms |
26220 KB |
Output is correct |
66 |
Correct |
205 ms |
24444 KB |
Output is correct |
67 |
Correct |
616 ms |
26852 KB |
Output is correct |
68 |
Correct |
505 ms |
25976 KB |
Output is correct |
69 |
Correct |
422 ms |
26340 KB |
Output is correct |
70 |
Correct |
617 ms |
26980 KB |
Output is correct |
71 |
Correct |
517 ms |
26088 KB |
Output is correct |
72 |
Correct |
411 ms |
26084 KB |
Output is correct |
73 |
Correct |
632 ms |
26212 KB |
Output is correct |
74 |
Correct |
168 ms |
25960 KB |
Output is correct |
75 |
Correct |
159 ms |
24812 KB |
Output is correct |
76 |
Correct |
166 ms |
28772 KB |
Output is correct |
77 |
Correct |
186 ms |
28772 KB |
Output is correct |
78 |
Correct |
347 ms |
43352 KB |
Output is correct |
79 |
Correct |
642 ms |
26776 KB |
Output is correct |
80 |
Correct |
409 ms |
27320 KB |
Output is correct |
81 |
Correct |
178 ms |
24684 KB |
Output is correct |
82 |
Correct |
397 ms |
28008 KB |
Output is correct |
83 |
Correct |
391 ms |
27624 KB |
Output is correct |
84 |
Correct |
558 ms |
25532 KB |
Output is correct |
85 |
Correct |
360 ms |
27364 KB |
Output is correct |
86 |
Correct |
345 ms |
26984 KB |
Output is correct |
87 |
Correct |
357 ms |
25828 KB |
Output is correct |
88 |
Correct |
354 ms |
31464 KB |
Output is correct |
89 |
Correct |
348 ms |
27316 KB |
Output is correct |
90 |
Correct |
181 ms |
31204 KB |
Output is correct |
91 |
Correct |
177 ms |
25736 KB |
Output is correct |
92 |
Correct |
362 ms |
27124 KB |
Output is correct |
93 |
Correct |
531 ms |
25924 KB |
Output is correct |
94 |
Correct |
407 ms |
30436 KB |
Output is correct |
95 |
Correct |
390 ms |
26084 KB |
Output is correct |
96 |
Correct |
182 ms |
28516 KB |
Output is correct |
97 |
Correct |
196 ms |
35428 KB |
Output is correct |
98 |
Correct |
203 ms |
35812 KB |
Output is correct |
99 |
Correct |
188 ms |
31208 KB |
Output is correct |
100 |
Correct |
145 ms |
31464 KB |
Output is correct |
101 |
Correct |
240 ms |
43352 KB |
Output is correct |
102 |
Correct |
180 ms |
29920 KB |
Output is correct |
103 |
Correct |
303 ms |
27112 KB |
Output is correct |