結果
問題 | No.2207 pCr検査 |
ユーザー |
|
提出日時 | 2023-02-09 18:37:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 969 bytes |
コンパイル時間 | 1,692 ms |
コンパイル使用メモリ | 171,100 KB |
実行使用メモリ | 265,072 KB |
最終ジャッジ日時 | 2024-07-06 20:25:09 |
合計ジャッジ時間 | 62,706 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 TLE * 4 |
ソースコード
#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; }