# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
255769305 |
Practice:
noob71 |
1955C
- 18
|
C++17 (GCC 7-32)
|
Time limit exceeded on test 3
|
2000 ms
|
12 KB
|
2024-04-08 20:59:33 |
2024-04-08 20:59:33 |
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,k;
cin>>t;
while(t--){
cin>>n>>k;
deque<int>q;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
q.push_back(v[i]);
}
int init = q.size();
int i= 1;
while(k != 0 && q.size() != 0){
if(i % 2 == 0){
--q.back();
}
else{
--q.front();
}
k--;
i++;
if(q.front() == 0){
q.pop_front();
continue;
}
if(q.back() == 0){
q.pop_back();
continue;
}
}
cout<<init-q.size()<<endl;
}
}
Click to see test details