제출 #406892

#제출 시각아이디문제언어결과실행 시간메모리
406892Ruxandra985The short shank; Redemption (BOI21_prison)C++14
0 / 100
165 ms20876 KiB
#include <bits/stdc++.h> #define DIMN 2000010 using namespace std; int v[DIMN] , w[DIMN] , f[DIMN] , out[DIMN]; pair <int , int> ev[2 * DIMN] , idk[DIMN]; priority_queue <int> h; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , d , t , sol , i , elem = 0 , e = 0 , pmax , j; fscanf (fin,"%d%d%d",&n,&d,&t); sol = 0; for (i = 1 ; i <= n ; i++){ fscanf (fin,"%d",&v[i]); if (v[i] > t){ w[++elem] = i; } else sol++; } for (i = 1 ; i <= n ; i++){ if (v[i] < t){ /// cauti in w intervalul de influenta pmax = min(n , i + t - v[i]); ev[++e] = make_pair(i , i); ev[++e] = make_pair(pmax + 1 , -i); } } sort (ev + 1 , ev + e + 1); i = 1; j = 1; while (j <= elem){ while (i <= e && ev[i].first <= w[j]){ /// procesezi ev[i] if (ev[i].second > 0) h.push(ev[i].second); else { out[-ev[i].second] = 1; /// il scoti } i++; } /// acum vezi w[j] ce tata are while (!h.empty() && out[h.top()]) h.pop(); if (!h.empty()) f[h.top()]++; /// h.top e cel mai din dreapta care il afecteaza pe w[j] j++; } for (i = 1 ; i <= n ; i++){ idk[i] = make_pair(f[i] , i); } sort (idk + 1 , idk + n + 1); for (i = 1 ; i <= n - d ; i++) sol += idk[i].first; fprintf (fout,"%d",sol); return 0; }

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

prison.cpp: In function 'int main()':
prison.cpp:12:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     fscanf (fin,"%d%d%d",&n,&d,&t);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:15:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         fscanf (fin,"%d",&v[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...