結果

問題 No.945 YKC饅頭
コンテスト
ユーザー kotatsugame
提出日時 2019-12-09 02:18:23
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 724 ms
コンパイル使用メモリ 91,360 KB
実行使用メモリ 17,104 KB
最終ジャッジ日時 2026-06-06 12:35:24
合計ジャッジ時間 8,300 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #
raw source code

#include<iostream>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,pair<int,int> > >A[2<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int L,R;char c;cin>>L>>R>>c;
		A[L-1].push_back(make_pair(i,make_pair(R,c=='Y'?0:c=='K'?1:2)));
	}
	priority_queue<pair<int,pair<int,int> > >P;
	int ans[3]={};
	for(int i=0;i<N;i++)
	{
		for(pair<int,pair<int,int> >p:A[i])
		{
			P.push(make_pair(-p.first,p.second));
		}
		while(!P.empty()&&P.top().second.first<=i)P.pop();
		if(!P.empty())
		{
			ans[P.top().second.second]++;
		}
	}
	cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;
}
0