# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
964691 |
2024-04-17T10:44:02 Z |
pcc |
Trading (IZhO13_trading) |
C++17 |
|
197 ms |
29676 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 3e5+10;
ll N,M;
vector<pii> op[mxn];
multiset<int> st;
int ans[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 0;i<M;i++){
int a,b,c;
cin>>a>>b>>c;
op[a].push_back(pii(c-a,1));
op[b+1].push_back(pii(c-a,-1));
}
for(int i = 1;i<=N;i++){
for(auto &j:op[i]){
if(j.sc>0)st.insert(j.fs);
else st.erase(st.find(j.fs));
}
if(st.empty())ans[i] = 0;
else ans[i] = *st.rbegin()+i;
}
for(int i = 1;i<=N;i++)cout<<ans[i]<<' ';cout<<'\n';
return 0;
}
Compilation message
trading.cpp: In function 'int main()':
trading.cpp:34:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
34 | for(int i = 1;i<=N;i++)cout<<ans[i]<<' ';cout<<'\n';
| ^~~
trading.cpp:34:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
34 | for(int i = 1;i<=N;i++)cout<<ans[i]<<' ';cout<<'\n';
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8288 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
3 ms |
8540 KB |
Output is correct |
6 |
Correct |
4 ms |
8540 KB |
Output is correct |
7 |
Correct |
107 ms |
19116 KB |
Output is correct |
8 |
Correct |
115 ms |
20676 KB |
Output is correct |
9 |
Correct |
102 ms |
21436 KB |
Output is correct |
10 |
Correct |
152 ms |
22704 KB |
Output is correct |
11 |
Correct |
119 ms |
22700 KB |
Output is correct |
12 |
Correct |
145 ms |
25176 KB |
Output is correct |
13 |
Correct |
148 ms |
23220 KB |
Output is correct |
14 |
Correct |
149 ms |
24248 KB |
Output is correct |
15 |
Correct |
167 ms |
26104 KB |
Output is correct |
16 |
Correct |
186 ms |
25516 KB |
Output is correct |
17 |
Correct |
197 ms |
25792 KB |
Output is correct |
18 |
Correct |
185 ms |
29676 KB |
Output is correct |
19 |
Correct |
188 ms |
26308 KB |
Output is correct |
20 |
Correct |
196 ms |
28952 KB |
Output is correct |