提出 #7708227
ソースコード 拡げる
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
(*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
(*arr)=(T*)(*mem);
(*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
sort(a, a+N);
}
inline void rd(int &x){
int k;
int m=0;
x=0;
for(;;){
k = getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline void wt_L(char a){
putchar_unlocked(a);
}
inline void wt_L(int x){
int s=0;
int m=0;
char f[10];
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
putchar_unlocked('-');
}
while(s--){
putchar_unlocked(f[s]+'0');
}
}
int N;
int K;
int A[5000];
int main(){
wmem = memarr;
int res;
bitset<5001> dp;
rd(N);
rd(K);
{
int Lj4PdHRW;
for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
rd(A[Lj4PdHRW]);
}
}
sortA_L(N,A);
while(N && A[N-1] >= K){
N--;
}
int KL2GvlyY;
int Q5VJL1cS;
int e98WHCEY;
KL2GvlyY = 0;
Q5VJL1cS = N;
while(KL2GvlyY < Q5VJL1cS){
int i;
if((KL2GvlyY + Q5VJL1cS)%2==0){
e98WHCEY = (KL2GvlyY + Q5VJL1cS) / 2;
}
else{
e98WHCEY = (KL2GvlyY + Q5VJL1cS + 1) / 2;
}
dp.reset();
dp[0] = true;
for(i=(0);i<(N);i++){
if(i!=e98WHCEY-1){
dp |= (dp << A[i]);
}
}
for(i=(K-A[e98WHCEY-1]);i<(K);i++){
if(dp[i]){
break;
}
}
if(i==K){
KL2GvlyY = e98WHCEY;
}
else{
Q5VJL1cS = e98WHCEY - 1;
}
}
res =Q5VJL1cS;
wt_L(res);
wt_L('\n');
return 0;
}
// cLay varsion 20190925-1
// --- original code ---
// int N, K, A[5000];
// {
// int res;
// bitset<5001> dp;
// rd(N,K,A(N));
// sortA(N,A);
// while(N && A[N-1] >= K) N--;
// res = bsearch_max[int,x,0,N][
// dp.reset();
// dp[0] = true;
// rep(i,N) if(i!=x-1) dp |= (dp << A[i]);
// rep(i,K-A[x-1],K) if(dp[i]) break;
// ](i==K);
// wt(res);
// }
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - No Need |
| ユーザ | LayCurse |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 600 |
| コード長 | 2535 Byte |
| 結果 | AC |
| 実行時間 | 14 ms |
| メモリ | 256 KiB |
ジャッジ結果
| セット名 | Sample | Subtask | All | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | 300 / 300 | ||||||
| 結果 |
|
|
|
| セット名 | テストケース |
|---|---|
| Sample | 0_000.txt, 0_001.txt, 0_002.txt |
| Subtask | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt |
| All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt, 2_030.txt, 2_031.txt, 2_032.txt, 2_033.txt, 2_034.txt, 2_035.txt, 2_036.txt, 2_037.txt, 2_038.txt, 2_039.txt, 2_040.txt, 2_041.txt, 2_042.txt, 2_043.txt, 2_044.txt, 2_045.txt, 2_046.txt, 2_047.txt, 2_048.txt, 2_049.txt, 2_050.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_000.txt | AC | 1 ms | 256 KiB |
| 0_001.txt | AC | 1 ms | 256 KiB |
| 0_002.txt | AC | 1 ms | 256 KiB |
| 1_003.txt | AC | 1 ms | 256 KiB |
| 1_004.txt | AC | 1 ms | 256 KiB |
| 1_005.txt | AC | 1 ms | 256 KiB |
| 1_006.txt | AC | 1 ms | 256 KiB |
| 1_007.txt | AC | 1 ms | 256 KiB |
| 1_008.txt | AC | 2 ms | 256 KiB |
| 1_009.txt | AC | 2 ms | 256 KiB |
| 1_010.txt | AC | 1 ms | 256 KiB |
| 1_011.txt | AC | 1 ms | 256 KiB |
| 1_012.txt | AC | 1 ms | 256 KiB |
| 1_013.txt | AC | 1 ms | 256 KiB |
| 1_014.txt | AC | 1 ms | 256 KiB |
| 1_015.txt | AC | 2 ms | 256 KiB |
| 1_016.txt | AC | 1 ms | 256 KiB |
| 1_017.txt | AC | 1 ms | 256 KiB |
| 1_018.txt | AC | 1 ms | 256 KiB |
| 1_019.txt | AC | 1 ms | 256 KiB |
| 1_020.txt | AC | 2 ms | 256 KiB |
| 1_021.txt | AC | 2 ms | 256 KiB |
| 1_022.txt | AC | 1 ms | 256 KiB |
| 1_023.txt | AC | 1 ms | 256 KiB |
| 1_024.txt | AC | 1 ms | 256 KiB |
| 1_025.txt | AC | 1 ms | 256 KiB |
| 2_026.txt | AC | 1 ms | 256 KiB |
| 2_027.txt | AC | 1 ms | 256 KiB |
| 2_028.txt | AC | 1 ms | 256 KiB |
| 2_029.txt | AC | 13 ms | 256 KiB |
| 2_030.txt | AC | 14 ms | 256 KiB |
| 2_031.txt | AC | 1 ms | 256 KiB |
| 2_032.txt | AC | 1 ms | 256 KiB |
| 2_033.txt | AC | 1 ms | 256 KiB |
| 2_034.txt | AC | 1 ms | 256 KiB |
| 2_035.txt | AC | 1 ms | 256 KiB |
| 2_036.txt | AC | 9 ms | 256 KiB |
| 2_037.txt | AC | 1 ms | 256 KiB |
| 2_038.txt | AC | 1 ms | 256 KiB |
| 2_039.txt | AC | 1 ms | 256 KiB |
| 2_040.txt | AC | 1 ms | 256 KiB |
| 2_041.txt | AC | 10 ms | 256 KiB |
| 2_042.txt | AC | 10 ms | 256 KiB |
| 2_043.txt | AC | 5 ms | 256 KiB |
| 2_044.txt | AC | 7 ms | 256 KiB |
| 2_045.txt | AC | 7 ms | 256 KiB |
| 2_046.txt | AC | 7 ms | 256 KiB |
| 2_047.txt | AC | 7 ms | 256 KiB |
| 2_048.txt | AC | 7 ms | 256 KiB |
| 2_049.txt | AC | 6 ms | 256 KiB |
| 2_050.txt | AC | 5 ms | 256 KiB |