結果

問題 No.2207 pCr検査
ユーザー maksimmaksim
提出日時 2023-02-09 18:37:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,968 ms / 3,000 ms
コード長 969 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 168,396 KB
実行使用メモリ 265,108 KB
最終ジャッジ日時 2023-09-21 01:40:56
合計ジャッジ時間 54,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 619 ms
100,752 KB
testcase_01 AC 583 ms
99,616 KB
testcase_02 AC 1,098 ms
191,020 KB
testcase_03 AC 991 ms
166,164 KB
testcase_04 AC 922 ms
167,312 KB
testcase_05 AC 1,464 ms
221,356 KB
testcase_06 AC 710 ms
141,708 KB
testcase_07 AC 832 ms
148,004 KB
testcase_08 AC 811 ms
136,196 KB
testcase_09 AC 1,258 ms
195,436 KB
testcase_10 AC 628 ms
117,352 KB
testcase_11 AC 1,133 ms
189,652 KB
testcase_12 AC 2,474 ms
219,872 KB
testcase_13 AC 1,730 ms
171,040 KB
testcase_14 AC 838 ms
117,880 KB
testcase_15 AC 2,800 ms
218,464 KB
testcase_16 AC 1,550 ms
166,292 KB
testcase_17 AC 2,299 ms
196,076 KB
testcase_18 AC 1,924 ms
168,288 KB
testcase_19 AC 1,246 ms
143,480 KB
testcase_20 AC 1,639 ms
157,088 KB
testcase_21 AC 2,874 ms
243,264 KB
testcase_22 AC 2,968 ms
262,904 KB
testcase_23 AC 2,959 ms
265,108 KB
testcase_24 AC 922 ms
121,040 KB
testcase_25 AC 1,517 ms
160,288 KB
testcase_26 AC 1,447 ms
147,508 KB
testcase_27 AC 2,343 ms
189,616 KB
testcase_28 AC 1,903 ms
246,220 KB
testcase_29 AC 1,873 ms
246,368 KB
testcase_30 AC 1,880 ms
245,428 KB
testcase_31 AC 1,863 ms
245,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxn=1e7+5;
int cnt[maxn];int cnt1[maxn];bool used[maxn];int lp[maxn];vector<int> pr;
int sok=0;
void f1(int x,int val)
{
    sok-=(cnt1[x]==cnt[x]);cnt1[x]+=val;sok+=(cnt1[x]==cnt[x]);
}
void f(int x,int val)
{
    if(x==1) return;
    int o=lp[x];f1(o,val);
    f(x/o,val);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(int i=2;i<maxn;++i) {if(!used[i]) {pr.push_back(i);for(int j=i;j<maxn;j+=i) {used[j]=true;lp[j]=i;}}}
    int n;cin>>n;
    pair<int,int> a[n];int p=1;
    for(int i=0;i<n;++i) {cin>>a[i].first>>a[i].second;cnt[a[i].first]=a[i].second;p=max(p,a[i].first);}
    for(int p:pr) if(cnt[p]==0) ++sok;
    for(int i=1;i<=p-1;++i)
    {
        f(p-i+1,1);
        f(i,-1);
        if(sok==pr.size())
        {
            cout<<p<<' '<<i<<endl;
            return 0;
        }
    }
    cout<<(-1)<<' '<<(-1)<<endl;
    return 0;
}
0