結果
問題 | No.2221 Set X |
ユーザー |
|
提出日時 | 2023-02-17 23:43:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 163 ms / 2,000 ms |
コード長 | 306 bytes |
コンパイル時間 | 2,083 ms |
コンパイル使用メモリ | 195,256 KB |
最終ジャッジ日時 | 2025-02-10 18:22:10 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:2:263: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 2 | using namespace std;int main(){int N,an=1e9,x;cin>>N;vector<int>A(N);for(int &a:A)cin>>a;for(int i=1;i<=2*N;i++){int res=0,L=0;while(res*(i+1)<an&&L*i<=A.back()){auto p=lower_bound(A.begin(),A.end(),L*i);res++;L=(*p/i)+1;}if(an>res*(i+1))an=res*(i+1),x=i;}cout<<x<<endl<<an<<endl;} | ^ main.cpp:2:45: note: ‘x’ was declared here 2 | using namespace std;int main(){int N,an=1e9,x;cin>>N;vector<int>A(N);for(int &a:A)cin>>a;for(int i=1;i<=2*N;i++){int res=0,L=0;while(res*(i+1)<an&&L*i<=A.back()){auto p=lower_bound(A.begin(),A.end(),L*i);res++;L=(*p/i)+1;}if(an>res*(i+1))an=res*(i+1),x=i;}cout<<x<<endl<<an<<endl;} | ^
ソースコード
#include <bits/stdc++.h> using namespace std;int main(){int N,an=1e9,x;cin>>N;vector<int>A(N);for(int &a:A)cin>>a;for(int i=1;i<=2*N;i++){int res=0,L=0;while(res*(i+1)<an&&L*i<=A.back()){auto p=lower_bound(A.begin(),A.end(),L*i);res++;L=(*p/i)+1;}if(an>res*(i+1))an=res*(i+1),x=i;}cout<<x<<endl<<an<<endl;}