# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
672972 | Cutebol | Trading (IZhO13_trading) | C++17 | 1 ms | 276 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define Scaramouche ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define itn int
#define endl "\n"
#define ff first
#define ss second
const int N = 2e5 + 5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e12 ;
int n , m ;
set < pair <int , int> , greater<pair <int , int> > > cur ;
vector <pair <int , pair <int , int> > >st ;
vector <int> ans ;
void solve(){
cin >> n >> m ;
for ( int i = 0 ; i < m ; i ++ ){
int x , y , v ;
cin >> x >> y >> v ;
st.push_back({x,{v,y}}) ;
}
sort ( st.begin() , st.end() ) ;
int ind = 0 ;
cur.insert({0,inf}) ;
for ( int i = 1 ; i <= n ; i ++ ){
while ( ind < m && st[ind].ff == i ){
cur.insert({st[ind].ss.ff,st[ind].ss.ss}) ;
ind ++ ;
}
pair <int , int> t = *cur.begin() ;
ans.push_back(t.ff) ;
cur.erase(cur.begin()) ;
if ( t.ff != 0 ) t.ff ++ ;
cur.insert(t) ;
while ( t.ss <= i ){
cur.erase(cur.begin()) ;
t = *cur.begin() ;
}
}
for ( auto i : ans ) cout << i << ' ' ;
}
signed main(){
// fopn("blocks") ;
// Scaramouche ;
int t = 1 ;
// cin >> t ;
while ( t -- ) solve() ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |