結果
| 問題 |
No.206 数の積集合を求めるクエリ
|
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-05-24 15:54:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 863 bytes |
| コンパイル時間 | 659 ms |
| コンパイル使用メモリ | 74,436 KB |
| 実行使用メモリ | 12,024 KB |
| 最終ジャッジ日時 | 2024-07-06 06:47:32 |
| 合計ジャッジ時間 | 10,970 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 1 -- * 6 |
ソースコード
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
int main(){
int L,M,N;
cin >> L >> M >> N;
int A[L],B[M];
for(int i=0;i<L;i++) cin>>A[i];
sort(A,A+L);
for(int i=0;i<M;i++) cin>>B[i];
sort(B,B+M);
priority_queue<pair<int,int> > pq;
int nxtInd=0;
for(int i=0;i<M;i++){
while( nxtInd<L && B[i]>A[nxtInd] ) nxtInd++;
if( nxtInd<L ){
pq.push(make_pair(B[i]-A[nxtInd],nxtInd));
}
}
int Q;
cin>>Q;
for( int i = 0 ; i < Q; i++ ){
int ans=0;
while( !pq.empty() ){
pair<int,int> p=pq.top();
if( p.first+i!=0 ) break;
pq.pop();
ans++;
if( p.second+1 < L){
pq.push(make_pair( p.first+A[p.second]-A[p.second+1], p.second+1));
}
}
cout << ans << endl;
}
return 0;
}
yaoshimax