結果
| 問題 | No.120 傾向と対策:門松列(その1) |
| コンテスト | |
| ユーザー |
eri
|
| 提出日時 | 2015-08-02 02:39:25 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 491 bytes |
| 記録 | |
| コンパイル時間 | 655 ms |
| コンパイル使用メモリ | 98,144 KB |
| 実行使用メモリ | 105,984 KB |
| 最終ジャッジ日時 | 2026-04-01 15:59:01 |
| 合計ジャッジ時間 | 1,262 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:41: warning: ignoring return value of 'std::priority_queue<_Tp, _Sequence, _Compare>::const_reference std::priority_queue<_Tp, _Sequence, _Compare>::top() const [with _Tp = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; const_reference = const int&]', declared with attribute 'nodiscard' [-Wunused-result]
21 | REP(i, 3) pq.top(), pq.pop();
| ~~~~~~^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/queue:72,
from main.cpp:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_queue.h:823:7: note: declared here
823 | top() const
| ^~~
ソースコード
#include<iostream>
#include<map>
#include<queue>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;
int main(){
int t; cin >> t;
while (t--){
map<int, int> mp;
int n; cin >> n;
REP(i,n){
int l; cin >> l;
mp[l]++;
}
priority_queue<int> pq;
for (auto it : mp) pq.push(it.second);
int ans = 0;
while (pq.size() >= 3){
ans++;
int x[3];
REP(i, 3) pq.top(), pq.pop();
REP(i, 3) if (x[i] > 1) pq.push(x[i] - 1);
}
cout << ans << endl;
}
return 0;
}
eri