Submission #3994979
Source Code Expand
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
//-------------------------↓↓↓↓↓↓------------------------
bool check(ll i){
bitset<5005> dp;
dp[0]=true;
rep(j,n){
if(i==j)continue;
dp|=dp<<a[j];
}
b=0;
rep(j,k){
if(!dp[j])continue;
if(j+a[i]>=k){
b=1;
break;
}
}
if(!b)return false;
else return true;
}
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>n>>k;
rep(i,n)cin>>a[i];
sort(a,a+n);
ll le=0,ri=n-1,mid;
while(ri-le>1){
mid=(le+ri)/2;
if(check(mid))ri=mid;
else le=mid;
}
rrrep(i,max(ri+500,n-1),min(le-500,0LL)){
bitset<5005> dp;
dp[0]=true;
rep(j,n){
if(i==j)continue;
dp|=dp<<a[j];
}
b=0;
rep(j,k){
if(!dp[j])continue;
if(j+a[i]>=k){
b=1;
break;
}
}
if(!b){
Cout(i+1);
break;
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
D - No Need |
User |
asdf1 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1770 Byte |
Status |
WA |
Exec Time |
2103 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
Subtask |
All |
Score / Max Score |
0 / 0 |
0 / 300 |
0 / 300 |
Status |
|
|
|
Set Name |
Test Cases |
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 |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
WA |
1 ms |
256 KB |
0_001.txt |
WA |
1 ms |
256 KB |
0_002.txt |
WA |
1 ms |
256 KB |
1_003.txt |
WA |
1 ms |
256 KB |
1_004.txt |
WA |
1 ms |
256 KB |
1_005.txt |
WA |
1 ms |
256 KB |
1_006.txt |
WA |
1 ms |
256 KB |
1_007.txt |
WA |
1 ms |
256 KB |
1_008.txt |
WA |
2 ms |
256 KB |
1_009.txt |
WA |
2 ms |
256 KB |
1_010.txt |
WA |
2 ms |
256 KB |
1_011.txt |
WA |
2 ms |
256 KB |
1_012.txt |
WA |
2 ms |
256 KB |
1_013.txt |
WA |
2 ms |
256 KB |
1_014.txt |
WA |
2 ms |
256 KB |
1_015.txt |
WA |
2 ms |
256 KB |
1_016.txt |
WA |
1 ms |
256 KB |
1_017.txt |
WA |
1 ms |
256 KB |
1_018.txt |
WA |
1 ms |
256 KB |
1_019.txt |
WA |
2 ms |
256 KB |
1_020.txt |
WA |
2 ms |
256 KB |
1_021.txt |
WA |
2 ms |
256 KB |
1_022.txt |
WA |
2 ms |
256 KB |
1_023.txt |
WA |
2 ms |
256 KB |
1_024.txt |
WA |
2 ms |
256 KB |
1_025.txt |
WA |
2 ms |
256 KB |
2_026.txt |
WA |
1 ms |
256 KB |
2_027.txt |
WA |
1 ms |
256 KB |
2_028.txt |
WA |
1 ms |
256 KB |
2_029.txt |
TLE |
2103 ms |
256 KB |
2_030.txt |
WA |
18 ms |
256 KB |
2_031.txt |
TLE |
2103 ms |
256 KB |
2_032.txt |
TLE |
2103 ms |
256 KB |
2_033.txt |
TLE |
2103 ms |
256 KB |
2_034.txt |
TLE |
2103 ms |
256 KB |
2_035.txt |
TLE |
2103 ms |
256 KB |
2_036.txt |
TLE |
2103 ms |
256 KB |
2_037.txt |
WA |
1 ms |
256 KB |
2_038.txt |
WA |
1 ms |
256 KB |
2_039.txt |
WA |
1 ms |
256 KB |
2_040.txt |
TLE |
2103 ms |
256 KB |
2_041.txt |
TLE |
2103 ms |
256 KB |
2_042.txt |
TLE |
2103 ms |
256 KB |
2_043.txt |
AC |
1872 ms |
256 KB |
2_044.txt |
TLE |
2103 ms |
256 KB |
2_045.txt |
TLE |
2103 ms |
256 KB |
2_046.txt |
TLE |
2103 ms |
256 KB |
2_047.txt |
TLE |
2103 ms |
256 KB |
2_048.txt |
TLE |
2103 ms |
256 KB |
2_049.txt |
TLE |
2103 ms |
256 KB |
2_050.txt |
TLE |
2103 ms |
256 KB |