제출 #425048

#제출 시각아이디문제언어결과실행 시간메모리
425048zoooma13The short shank; Redemption (BOI21_prison)C++14
0 / 100
1 ms292 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n ,k ,T;
    scanf("%d%d%d",&n,&k,&T);
    assert(k == 1);
    vector <int> a(n);
    for(int&i : a)
        scanf("%d",&i);

    int ans = 0;
    vector <pair<int ,int>> rs;
    deque <pair<int ,int>> q;
    for(int i = 0; i < n; i++){
        while(!q.empty() && q.front().first >= T-i)
            q.pop_front();
        if(a[i] < T){
            while(!q.empty() && q.back().first >= a[i]-i)
                q.pop_back();
            q.push_back({a[i]-i ,i});
        }else if(!q.empty())
            rs.push_back({q.back().second ,i-1});
        else
            ans++;
    }

    vector <int> cum(n+1);
    for(auto&p : rs){
        cum[p.first]++;
        cum[p.second+1]--;
    }

    int mx = 0;
    for(int i = 0; i < n; i++){
        cum[i] += i? cum[i-1] : 0;
        mx = max(mx ,cum[i]);
    }

    printf("%d\n",n-ans-mx);
}

컴파일 시 표준 에러 (stderr) 메시지

prison.cpp: In function 'int main()':
prison.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d%d",&n,&k,&T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
prison.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...