# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884402 | lalig777 | Telefoni (COCI17_telefoni) | C++14 | 45 ms | 1624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
int n, d;
cin>>n>>d;
vector<int>telefoni(n);
priority_queue<pair<int,int>, vector<pair<int, int> >, greater<pair<int,int> > >pq;
pq.push(make_pair(0, 0));
cin>>telefoni[0];
telefoni[0]=0;
for (int i=1; i<n; i++){
cin>>telefoni[i];
if (telefoni[i]==0) telefoni[i]=1;
else telefoni[i]=0;
while (!pq.empty()){
if (i-pq.top().second>d) pq.pop();
else{
telefoni[i]+=pq.top().first;
pq.push(make_pair(telefoni[i], i));
break;
}
}
}cout<<telefoni[n-1]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |