# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
288871 | 2020-09-02T04:24:48 Z | mohammedehab2002 | 별자리 3 (JOI20_constellation3) | C++11 | 1500 ms | 28536 KB |
#include <bits/stdc++.h> using namespace std; long long w[200005],ans; vector<int> v[200005]; pair<pair<int,int>,int> s[200005]; int a[200005],pre[200005],nex[200005]; int main() { int n,m; scanf("%d",&n); for (int i=1;i<=n;i++) { scanf("%d",&a[i]); a[i]=n-a[i]; } scanf("%d",&m); for (int i=0;i<m;i++) { scanf("%d%d%d",&s[i].first.second,&s[i].first.first,&s[i].second); s[i].first.first=n-s[i].first.first+1; ans+=s[i].second; } sort(s,s+m); reverse(s,s+m); for (int i=0;i<m;i++) v[s[i].first.second].push_back(i); stack<int> st; set<pair<int,int> > idx; st.push(0); idx.insert({0,0}); for (int i=1;i<=n;i++) { while (!st.empty() && a[i]<=a[st.top()]) { idx.erase({a[st.top()],st.top()}); st.pop(); } for (int j:v[i]) pre[j]=(*prev(idx.upper_bound({s[j].first.first,-1}))).second+1; st.push(i); idx.insert({a[i],i}); } while (!st.empty()) st.pop(); idx.clear(); st.push(n+1); idx.insert({0,n+1}); for (int i=n;i>0;i--) { while (!st.empty() && a[i]<=a[st.top()]) { idx.erase({a[st.top()],st.top()}); st.pop(); } for (int j:v[i]) nex[j]=(*prev(idx.upper_bound({s[j].first.first,-1}))).second-1; st.push(i); idx.insert({a[i],i}); } for (int i=0;i<m;i++) { long long v=s[i].second+w[s[i].first.second]; if (v>0) { ans-=v; for (int j=pre[i];j<=nex[i];j++) w[j]-=v; } } printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5120 KB | Output is correct |
2 | Correct | 3 ms | 5120 KB | Output is correct |
3 | Correct | 4 ms | 5120 KB | Output is correct |
4 | Correct | 4 ms | 5120 KB | Output is correct |
5 | Correct | 4 ms | 5120 KB | Output is correct |
6 | Correct | 3 ms | 5120 KB | Output is correct |
7 | Correct | 4 ms | 5120 KB | Output is correct |
8 | Correct | 4 ms | 5120 KB | Output is correct |
9 | Correct | 4 ms | 5120 KB | Output is correct |
10 | Correct | 4 ms | 5120 KB | Output is correct |
11 | Correct | 4 ms | 5120 KB | Output is correct |
12 | Correct | 4 ms | 5120 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 4 ms | 5120 KB | Output is correct |
16 | Correct | 4 ms | 5120 KB | Output is correct |
17 | Correct | 4 ms | 5120 KB | Output is correct |
18 | Correct | 4 ms | 5120 KB | Output is correct |
19 | Correct | 4 ms | 5120 KB | Output is correct |
20 | Correct | 4 ms | 5120 KB | Output is correct |
21 | Correct | 4 ms | 5120 KB | Output is correct |
22 | Correct | 4 ms | 5120 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5120 KB | Output is correct |
2 | Correct | 3 ms | 5120 KB | Output is correct |
3 | Correct | 4 ms | 5120 KB | Output is correct |
4 | Correct | 4 ms | 5120 KB | Output is correct |
5 | Correct | 4 ms | 5120 KB | Output is correct |
6 | Correct | 3 ms | 5120 KB | Output is correct |
7 | Correct | 4 ms | 5120 KB | Output is correct |
8 | Correct | 4 ms | 5120 KB | Output is correct |
9 | Correct | 4 ms | 5120 KB | Output is correct |
10 | Correct | 4 ms | 5120 KB | Output is correct |
11 | Correct | 4 ms | 5120 KB | Output is correct |
12 | Correct | 4 ms | 5120 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 4 ms | 5120 KB | Output is correct |
16 | Correct | 4 ms | 5120 KB | Output is correct |
17 | Correct | 4 ms | 5120 KB | Output is correct |
18 | Correct | 4 ms | 5120 KB | Output is correct |
19 | Correct | 4 ms | 5120 KB | Output is correct |
20 | Correct | 4 ms | 5120 KB | Output is correct |
21 | Correct | 4 ms | 5120 KB | Output is correct |
22 | Correct | 4 ms | 5120 KB | Output is correct |
23 | Correct | 5 ms | 5120 KB | Output is correct |
24 | Correct | 5 ms | 5248 KB | Output is correct |
25 | Correct | 6 ms | 5248 KB | Output is correct |
26 | Correct | 5 ms | 5120 KB | Output is correct |
27 | Correct | 6 ms | 5248 KB | Output is correct |
28 | Correct | 5 ms | 5248 KB | Output is correct |
29 | Correct | 5 ms | 5120 KB | Output is correct |
30 | Correct | 6 ms | 5248 KB | Output is correct |
31 | Correct | 5 ms | 5248 KB | Output is correct |
32 | Correct | 6 ms | 5248 KB | Output is correct |
33 | Correct | 6 ms | 5248 KB | Output is correct |
34 | Correct | 6 ms | 5248 KB | Output is correct |
35 | Correct | 6 ms | 5248 KB | Output is correct |
36 | Correct | 5 ms | 5120 KB | Output is correct |
37 | Correct | 5 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5248 KB | Output is correct |
39 | Correct | 5 ms | 5120 KB | Output is correct |
40 | Correct | 6 ms | 5248 KB | Output is correct |
41 | Correct | 6 ms | 5120 KB | Output is correct |
42 | Correct | 6 ms | 5120 KB | Output is correct |
43 | Correct | 6 ms | 5248 KB | Output is correct |
44 | Correct | 5 ms | 5120 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5120 KB | Output is correct |
2 | Correct | 3 ms | 5120 KB | Output is correct |
3 | Correct | 4 ms | 5120 KB | Output is correct |
4 | Correct | 4 ms | 5120 KB | Output is correct |
5 | Correct | 4 ms | 5120 KB | Output is correct |
6 | Correct | 3 ms | 5120 KB | Output is correct |
7 | Correct | 4 ms | 5120 KB | Output is correct |
8 | Correct | 4 ms | 5120 KB | Output is correct |
9 | Correct | 4 ms | 5120 KB | Output is correct |
10 | Correct | 4 ms | 5120 KB | Output is correct |
11 | Correct | 4 ms | 5120 KB | Output is correct |
12 | Correct | 4 ms | 5120 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 4 ms | 5120 KB | Output is correct |
16 | Correct | 4 ms | 5120 KB | Output is correct |
17 | Correct | 4 ms | 5120 KB | Output is correct |
18 | Correct | 4 ms | 5120 KB | Output is correct |
19 | Correct | 4 ms | 5120 KB | Output is correct |
20 | Correct | 4 ms | 5120 KB | Output is correct |
21 | Correct | 4 ms | 5120 KB | Output is correct |
22 | Correct | 4 ms | 5120 KB | Output is correct |
23 | Correct | 5 ms | 5120 KB | Output is correct |
24 | Correct | 5 ms | 5248 KB | Output is correct |
25 | Correct | 6 ms | 5248 KB | Output is correct |
26 | Correct | 5 ms | 5120 KB | Output is correct |
27 | Correct | 6 ms | 5248 KB | Output is correct |
28 | Correct | 5 ms | 5248 KB | Output is correct |
29 | Correct | 5 ms | 5120 KB | Output is correct |
30 | Correct | 6 ms | 5248 KB | Output is correct |
31 | Correct | 5 ms | 5248 KB | Output is correct |
32 | Correct | 6 ms | 5248 KB | Output is correct |
33 | Correct | 6 ms | 5248 KB | Output is correct |
34 | Correct | 6 ms | 5248 KB | Output is correct |
35 | Correct | 6 ms | 5248 KB | Output is correct |
36 | Correct | 5 ms | 5120 KB | Output is correct |
37 | Correct | 5 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5248 KB | Output is correct |
39 | Correct | 5 ms | 5120 KB | Output is correct |
40 | Correct | 6 ms | 5248 KB | Output is correct |
41 | Correct | 6 ms | 5120 KB | Output is correct |
42 | Correct | 6 ms | 5120 KB | Output is correct |
43 | Correct | 6 ms | 5248 KB | Output is correct |
44 | Correct | 5 ms | 5120 KB | Output is correct |
45 | Correct | 289 ms | 20728 KB | Output is correct |
46 | Correct | 286 ms | 20600 KB | Output is correct |
47 | Correct | 291 ms | 20900 KB | Output is correct |
48 | Correct | 274 ms | 20344 KB | Output is correct |
49 | Correct | 287 ms | 20472 KB | Output is correct |
50 | Correct | 288 ms | 20344 KB | Output is correct |
51 | Correct | 288 ms | 20404 KB | Output is correct |
52 | Correct | 300 ms | 20856 KB | Output is correct |
53 | Correct | 295 ms | 20476 KB | Output is correct |
54 | Correct | 494 ms | 24184 KB | Output is correct |
55 | Correct | 500 ms | 23288 KB | Output is correct |
56 | Correct | 471 ms | 22392 KB | Output is correct |
57 | Correct | 449 ms | 22264 KB | Output is correct |
58 | Correct | 360 ms | 20332 KB | Output is correct |
59 | Correct | 367 ms | 20600 KB | Output is correct |
60 | Execution timed out | 1590 ms | 28536 KB | Time limit exceeded |
61 | Halted | 0 ms | 0 KB | - |