제출 #20249

#제출 시각아이디문제언어결과실행 시간메모리
20249petilTrading (IZhO13_trading)C++14
100 / 100
501 ms64 KiB
#include <cstdio>
#include <set>
#include <vector>
using namespace std;

int n, m;
struct info{
	int x, L, idx;
	info(int a, int b, int c) : x(a), L(b), idx(c){}
	bool operator<(const info &i)const{
		if (x == i.x){
			if (idx == i.idx)return L < i.L;
			return idx < i.idx;
		}
		return x > i.x;
	}
};
multiset < info > s;
vector<info> st[300003], ed[300003];
int ans[300003];
int main(){
	scanf("%d %d", &n, &m);
	for (int le, ri, x, i = 1; i <= m; i++){
		scanf("%d %d %d", &le, &ri, &x);
		st[le].push_back(info(x-le, le, i));
		ed[ri].push_back(info(x-le, le, i));
	}
	for (int day = 1; day <= n; day++){
		for (int i = 0; i < st[day].size(); i++)
			s.insert(info(st[day][i].x, st[day][i].L, st[day][i].idx));
		if (s.empty())ans[day] = 0;
		else{
			ans[day] = s.begin()->x + day;
		}
		for (int i = 0; i < ed[day].size(); i++){
			auto it = s.find(ed[day][i]);
			s.erase(it);
		}
	}
	for (int i = 1; i <= n; i++)printf("%d ", ans[i]);
}

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

trading.cpp: In function 'int main()':
trading.cpp:29:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < st[day].size(); i++)
                     ^
trading.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < ed[day].size(); i++){
                     ^
trading.cpp:22:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
trading.cpp:24:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &le, &ri, &x);
                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...