Submission #698070

#TimeUsernameProblemLanguageResultExecution timeMemory
698070Tien_NoobThe short shank; Redemption (BOI21_prison)C++17
0 / 100
1 ms340 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" using namespace std; const int N = 2e6; int n, T, cnt[N + 1], deg[N + 1], a[N + 1], d; struct FenwickTree { int tree[N + 1]; void add(int pos, int val) { pos = min(pos, val); for (; pos >= 0; pos = (pos & (pos + 1)) - 1) { tree[pos] = val; } } int get(int pos) { int ret = 0; for (; pos <= n; pos |= pos + 1) { ret = max(ret, tree[pos]); } return ret; } } tree; int res; void read() { cin >> n >> d >> T; for (int i = 1; i <= n; ++ i) { cin >> a[i]; if (a[i] > T) { int pre = tree.get(i); if (pre == 0) { ++res; } else { --cnt[deg[pre]]; ++deg[pre]; ++cnt[deg[pre]]; } } else { tree.add(T + i - a[i], i); } } } void solve() { for (int i = n; i >= 1; -- i) { while(cnt[i] > 0 && d > 0) { res += i; --cnt[i]; --d; } } cout << n - res; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }

Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...