結果

問題 No.2207 pCr検査
ユーザー 沙耶花沙耶花
提出日時 2023-02-03 21:46:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,319 ms / 3,000 ms
コード長 981 bytes
コンパイル時間 3,913 ms
コンパイル使用メモリ 260,004 KB
実行使用メモリ 120,376 KB
最終ジャッジ日時 2023-09-15 17:29:40
合計ジャッジ時間 29,026 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 253 ms
120,148 KB
testcase_01 AC 243 ms
120,100 KB
testcase_02 AC 620 ms
120,248 KB
testcase_03 AC 541 ms
120,200 KB
testcase_04 AC 493 ms
120,144 KB
testcase_05 AC 858 ms
120,376 KB
testcase_06 AC 343 ms
120,252 KB
testcase_07 AC 428 ms
120,244 KB
testcase_08 AC 429 ms
120,200 KB
testcase_09 AC 741 ms
120,208 KB
testcase_10 AC 257 ms
120,272 KB
testcase_11 AC 637 ms
120,248 KB
testcase_12 AC 940 ms
120,284 KB
testcase_13 AC 619 ms
120,252 KB
testcase_14 AC 328 ms
120,300 KB
testcase_15 AC 956 ms
120,144 KB
testcase_16 AC 593 ms
120,272 KB
testcase_17 AC 829 ms
120,360 KB
testcase_18 AC 679 ms
120,248 KB
testcase_19 AC 481 ms
120,336 KB
testcase_20 AC 591 ms
120,196 KB
testcase_21 AC 1,046 ms
120,248 KB
testcase_22 AC 1,319 ms
120,360 KB
testcase_23 AC 1,294 ms
120,344 KB
testcase_24 AC 343 ms
120,304 KB
testcase_25 AC 585 ms
120,208 KB
testcase_26 AC 536 ms
120,276 KB
testcase_27 AC 838 ms
120,200 KB
testcase_28 AC 1,143 ms
120,272 KB
testcase_29 AC 1,122 ms
120,288 KB
testcase_30 AC 1,128 ms
120,248 KB
testcase_31 AC 1,113 ms
120,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

constexpr int M = 10000001;
int main(){
	
	vector<int> mp(M,-1);
	for(int i=2;i<M;i++){
		if(mp[i]!=-1)continue;
		for(int j=i;j<M;j+=i)mp[j] = i;
	}
	vector<int> goal(M,0),cur(M,0);
	int ok = M;
	int m = 0;
	{
		int k;
		cin>>k;
		rep(i,k){
			int p,e;
			cin>>p>>e;
			goal[p] = e;
			ok--;
			m = max(m,p);
		}
	}
	
	rep(i,m/2){
		{
			int c = m-i;
			while(c!=1){
				int p = mp[c];
				if(cur[p]==goal[p])ok--;
				cur[p]++;
				if(cur[p]==goal[p])ok++;
				c /= p;
			}
		}
		{
			int c = i+1;
			while(c!=1){
				int p = mp[c];
				if(cur[p]==goal[p])ok--;
				cur[p]--;
				if(cur[p]==goal[p])ok++;
				c /= p;
			}
		}	
		if(ok==M){
			cout<<m<<' '<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<' '<<-1<<endl;
	
	return 0;
}
0