結果

問題 No.8016 unordered_mapなるたけ落とすマン
ユーザー hogeover30
提出日時 2016-05-22 01:55:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 996 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 170,096 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-07 06:10:13
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 40 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//using namespace std;int main(){long n,a;map<long,int>r;for(cin>>n>>a;cin>>a;--n<0?cout<<r[a]<<' ',0:++r[a]);}
using namespace std;

const int bufsize=14*100010;
char buf[bufsize];

long a[100010], c[100010];

long a2l(char* s)
{
    long res=0;
    for(char* p=s; *p; ++p) res=res*10+*p-'0';
    return res;
}

int main()
{
    fgets(buf, bufsize, stdin);
    int n, m; sscanf(buf, "%d%d", &n, &m);
    a[0]=a2l(strtok(fgets(buf, bufsize, stdin), " "));
    for(int i=1; i<n; ++i) a[i]=a2l(strtok(0, " "));
    sort(a, a+n);
    int k=0;
    c[k]=1;
    for(int i=1; i<n; ++i) {
        if (a[i]==a[i-1])
            ++c[k];
        else
            ++c[++k];
    }
    n=unique(a, a+n)-a;

    long b=a2l(strtok(fgets(buf, bufsize, stdin), " "));
    int p=lower_bound(a, a+n, b)-a;
    printf("%d ", a[p]==b ? c[p] : 0);
    for(int i=1; i<m; ++i) {
        b=a2l(strtok(0, " "));
        p=lower_bound(a, a+n, b)-a;
        printf("%d ", a[p]==b ? c[p] : 0);
    }
}
0