結果
問題 |
No.2221 Set X
|
ユーザー |
|
提出日時 | 2025-08-25 16:16:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 306 bytes |
コンパイル時間 | 2,106 ms |
コンパイル使用メモリ | 195,648 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-25 16:16:54 |
合計ジャッジ時間 | 7,169 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}