Submission #41324

#TimeUsernameProblemLanguageResultExecution timeMemory
41324wzyTrading (IZhO13_trading)C++11
100 / 100
391 ms31716 KiB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define F first
#define pb push_back
#define S second
int n , m , carry[300005];
vector<pii> st [300005], ed[300005]; 

multiset<pii> ans;

int main(){
	scanf("%d%d" , &n , &m);
	for(int i = 0 ; i < m ; i++){
		int l ,r , v;
		scanf("%d%d%d" , &l , &r , &v);
		st[l].pb(pii(r, v));
	}
	for(int i = 0 ; i <= n ; i++) carry[i] = 0;
	for(int i = 1 ; i <= n ; i++){
		while(!st[i].empty()){
			ans.insert(pii(i -st[i].back().S  , st[i].back().F));
			ed[st[i].back().F].pb(pii(pii( i - st[i].back().S  , st[i].back().F)));
			st[i].pop_back();
		}
		if(!ans.empty()){
			pii u = *ans.begin();
			carry[i] = max(carry[i] , i - u.F);
		}
		while(ed[i].size()){
			ans.erase(ans.find(ed[i].back()));
			ed[i].pop_back();
		}
	}
	for(int i = 1 ; i <= n; i++) printf("%d " , carry[i]);
}

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:13:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d" , &n , &m);
                         ^
trading.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d" , &l , &r , &v);
                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...