Submission #502127

#TimeUsernameProblemLanguageResultExecution timeMemory
502127AktanTrading (IZhO13_trading)C++17
100 / 100
547 ms33500 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define int long long #define ft first #define sc second using namespace std; const int mod=1e9+7,INF=1e17,N=3e5+5; int a[N],b[N],c[N]; main(){ int n,m; cin >> n >> m; multiset<pair<pair<int,int>,int>> v; for(int i=0;i<m;i++){ cin >> a[i] >> b[i] >> c[i]; v.insert({{a[i],b[i]},c[i]-a[i]}); } multiset<pair<int,int>> v1; for(int i=1;i<=n;i++){ while(!v.empty() && v.begin()->ft.ft<=i){ v1.insert({v.begin()->sc,v.begin()->ft.sc}); v.erase(v.begin()); } while(!v1.empty() && (--v1.end())->sc < i){ v1.erase((--v1.end())); } if(v1.empty()){ cout << 0 << " "; } else{ auto it=v1.end(); it--; cout << it->ft+i << " "; } } }

Compilation message (stderr)

trading.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...