結果
| 問題 | No.1460 Max of Min |
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-03-31 21:32:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 997 bytes |
| 記録 | |
| コンパイル時間 | 3,088 ms |
| コンパイル使用メモリ | 198,232 KB |
| 最終ジャッジ日時 | 2025-01-20 02:56:46 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 87 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d%llu\n",&K,&N);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:38:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | rep(i,K) scanf("%lld",&A[i]);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:40:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | rep(i,K) scanf("%lld",&B[i]); reverse(B.begin(),B.end());
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using BinArr = bitset<1000>;
BinArr mask;
int K;
ll N;
vector<ll> A,B;
vector<ll> ValArr;
BinArr precK(BinArr a, BinArr b){
BinArr res;
rep(i,K) if(b.test(i)) res|=a>>i;
BinArr res2;
rep(i,K) if(b.test(i)) res2|=a<<(K-i);
return res2 & mask;
}
bool solve(ll x){
BinArr Ax, Bx;
rep(i,K) if(A[i]>=x) Ax.set(i);
rep(i,K) if(B[i]>=x) Bx.set(i);
rep(i,N/K) Ax = precK(Ax,Bx);
return Ax.test(N%K);
}
int main(){
scanf("%d%llu\n",&K,&N);
N = min(N/K,(ll)K)*K+(N%K);
rep(i,K) mask.set(i);
A.resize(K);
rep(i,K) scanf("%lld",&A[i]);
B.resize(K);
rep(i,K) scanf("%lld",&B[i]); reverse(B.begin(),B.end());
rep(i,K) ValArr.push_back(A[i]);
rep(i,K) ValArr.push_back(B[i]);
int l=0, r=ValArr.size()+1;
while(r-l>1){
int m=(l+r)/2;
if(solve(ValArr[m])) l=m; else r=m;
}
printf("%lld\n",ValArr[l]);
return 0;
}
Nachia