제출 #690684

#제출 시각아이디문제언어결과실행 시간메모리
690684Kaztaev_AlisherTrading (IZhO13_trading)C++17
100 / 100
330 ms30432 KiB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long; 

const ll N = 300005 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;	
 
ll n , q;
vector<pair<ll,ll>> v[N];
multiset<ll> st;

void solve(){
	cin >> n >> q;
	while(q--){
		ll l , r , x;
		cin >> l >> r >> x;
		v[l].push_back({1 , x-l});
		v[r+1].push_back({0 , x-l});
	}
	for(ll i = 1; i <= n; i++){
		sort(all(v[i]));
		for(pair<ll,ll> x : v[i]){
			if(x.F == 1) st.insert(x.S);
			else st.erase(st.find(x.S));
		}
		if(st.size() == 0) cout << "0 ";
		else cout << *st.rbegin()+i <<" ";
	}
}
/*
 
*/
signed main(){
	ios;
	file("trading");
	solve();
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

trading.cpp: In function 'int main()':
trading.cpp:4:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
trading.cpp:42:2: note: in expansion of macro 'file'
   42 |  file("trading");
      |  ^~~~
trading.cpp:4:77: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
      |                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
trading.cpp:42:2: note: in expansion of macro 'file'
   42 |  file("trading");
      |  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...