# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
884402 | lalig777 | Telefoni (COCI17_telefoni) | C++14 | 45 ms | 1624 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |