結果
問題 |
No.3054 Modulo Inequalities
|
ユーザー |
![]() |
提出日時 | 2025-03-07 23:19:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,057 bytes |
コンパイル時間 | 2,480 ms |
コンパイル使用メモリ | 204,384 KB |
実行使用メモリ | 15,124 KB |
最終ジャッジ日時 | 2025-03-07 23:20:12 |
合計ジャッジ時間 | 45,874 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 17 RE * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define vi vector<int> #define vl vector<ll> #define vii vector<pair<int,int>> #define vll vector<pair<ll,ll>> #define vvi vector<vector<int>> #define vvl vector<vector<ll>> #define vvii vector<vector<pair<int,int>>> #define vvll vector<vector<pair<ll,ll>>> #define vst vector<string> #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define all(x) (x).begin(),(x).end() #define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end()) #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=15<<26; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int M=1000001; int N;cin>>N; vii S(N); int mib=M,mab=0; for(int i=0;i<N;i++){ cin>>S[i].fi>>S[i].se; if(S[i].fi<S[i].se){ chmax(mab,S[i].se+1); chmin(mib,S[i].se+1); } } shuffle(all(S),rng); vii A(M+1); for(int q=0;q<min(200,N);q++){ for(int i=1;i<=M;i++){ if(S[q].fi%i<S[q].se%i) A[i].fi++; } } A[1].fi=INF; A[mib].fi=INF; A[mab].fi=INF; for(int i=1;i<=M;i++) A[i].se=i; sort(all(A),[](auto a,auto b){ if(a.fi==b.fi) return a.se>b.se; else return a<b; }); reverse(all(A)); int ma=-1,ans=INF; for(int q=0;q<200;q++){ int cn=0; for(int i=0;i<N;i++){ if(S[i].fi%A[q].se<S[i].se%A[q].se) cn++; } if(chmax(ma,cn)) ans=A[q].se; else if(ma==cn) chmin(ans,A[q].se); //cout<<A[q].se<<" "<<cn<<endl; } cout<<ans<<endl; }