ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#193804 | #3399. average | mikefeng | 100 | 49ms | 3708kb | C++11 | 1.7kb | 2023-10-14 14:49:54 | 2023-10-14 18:37:42 |
answer
bool M1;
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<iomanip>
#include<cassert>
#include<random>
#include<cstdio>
#include<vector>
#include<bitset>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
//#include<ext/pb_ds/priority_queue.hpp>
#define fi first
#define se second
#define LD double
#define name(x) #x
#define ll long long
#define Vector Point
#define I128 __int128
#define ull unsigned ll
#define pii pair<ll,ll>
#define pb(x) push_back(x)
#define dek(x) debug(x)<<" "
#define deh(x) debug(x)<<endl
#define syt cerr<<"sytakioi\n"
#define debug(x) cout<<name(x)<<":"<<x
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<'\n'
#define rd_i(l,r) uniform_int_distribution<int>(l,r)(rd)
#define rd_r(l,r) uniform_real_distribution<double>(l,r)(rd)
#define look_time cerr<<(clock()-Time)*1.0/CLOCKS_PER_SEC<<'\n'
using namespace std;
//using namespace __gnu_cxx;
mt19937 rd(time(0));
const int N=1e5+5;
int n,k;
int a[N],b[N];
ll mn[N],sum[N];
int s[N];
inline bool check(int x){
F(i,1,n) b[i]=a[i]-x,sum[i]=sum[i-1]+b[i],mn[i]=min(mn[i-1],sum[i]);
F(i,k,n) if(sum[i]-mn[i-k]>=0) return 1;
return 0;
}
bool M2;
int main(){
int Time=clock();
look_memory;
cin.tie(nullptr)->sync_with_stdio(false);
cin>>n>>k;
F(i,1,n) cin>>a[i];
int l=1,r=1e9,ans=1;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid)) l=mid+1,ans=mid;
else r=mid-1;
}
cout<<ans<<'\n';
look_time;
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 20
Accepted
time: 0ms
memory: 1404kb
input:
1000 100 332109541 265698305 339007233 386487277 65597920 217218907 436378017 221884663 270433433 26...
output:
334924174
result:
ok single line: '334924174'
Test #2:
score: 20
Accepted
time: 0ms
memory: 1404kb
input:
1000 100 108652253 396843081 18739163 168730297 41598432 22132831 155692945 617160601 164753707 8614...
output:
323746083
result:
ok single line: '323746083'
Test #3:
score: 20
Accepted
time: 0ms
memory: 1404kb
input:
1000 100 71158753 11073019 119630785 162780801 25368543 517705 123835636 254874371 4127795 157084999...
output:
338258685
result:
ok single line: '338258685'
Test #4:
score: 20
Accepted
time: 23ms
memory: 3708kb
input:
100000 10 227552529 170886571 513851125 46675201 188079376 255537313 266819605 69661658 214521435 33...
output:
642253260
result:
ok single line: '642253260'
Test #5:
score: 20
Accepted
time: 26ms
memory: 3704kb
input:
100000 100 227552529 170886571 513851125 46675201 188079376 255537313 266819605 69661658 214521435 3...
output:
353627389
result:
ok single line: '353627389'