結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 777 ms
100,492 KB
testcase_01 AC 772 ms
100,240 KB
testcase_02 AC 1,350 ms
194,412 KB
testcase_03 AC 1,208 ms
170,208 KB
testcase_04 AC 1,143 ms
167,008 KB
testcase_05 AC 1,708 ms
221,976 KB
testcase_06 AC 884 ms
140,396 KB
testcase_07 AC 1,005 ms
147,904 KB
testcase_08 AC 982 ms
137,688 KB
testcase_09 AC 1,486 ms
195,328 KB
testcase_10 AC 807 ms
117,980 KB
testcase_11 AC 1,395 ms
188,588 KB
testcase_12 AC 1,935 ms
214,204 KB
testcase_13 AC 1,391 ms
170,428 KB
testcase_14 AC 879 ms
117,068 KB
testcase_15 AC 2,066 ms
216,404 KB
testcase_16 AC 1,347 ms
165,928 KB
testcase_17 AC 1,862 ms
195,932 KB
testcase_18 AC 1,569 ms
167,336 KB
testcase_19 AC 1,139 ms
144,304 KB
testcase_20 AC 1,355 ms
158,296 KB
testcase_21 AC 2,158 ms
239,684 KB
testcase_22 AC 2,296 ms
264,532 KB
testcase_23 AC 2,234 ms
262,984 KB
testcase_24 AC 965 ms
121,088 KB
testcase_25 AC 1,335 ms
160,240 KB
testcase_26 AC 1,311 ms
147,216 KB
testcase_27 AC 1,862 ms
189,324 KB
testcase_28 AC 2,215 ms
245,552 KB
testcase_29 AC 2,134 ms
246,544 KB
testcase_30 AC 2,176 ms
246,952 KB
testcase_31 AC 2,187 ms
245,792 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/2;++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