제출 #971536

#제출 시각아이디문제언어결과실행 시간메모리
971536CyberCowThe short shank; Redemption (BOI21_prison)C++17
55 / 100
2051 ms12884 KiB
#include <random> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <chrono> #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((x).size()) typedef long long ll; using ull = unsigned long long; using namespace std; mt19937 rnd(348502); ll mod1 = 998244353; ll mod = 1e9 + 7; const ll N = 500010; int a[N], lr[N]; int han[N]; int ans[N]; int achqisjoga[N]; void solve() { int n, d, k, t; cin >> n >> d >> t; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] <= t) lr[i] = min(t - a[i] + i, n); } int obshi = 0; int ma = 0, qaq = 0; for (int h = 0; h < d; h++) { obshi = 0; stack<pair<int, int>> se; for (int i = 1; i <= n; i++) { se.push({ i, lr[i] }); while (!se.empty() && se.top().second < i) { se.pop(); } if (!se.empty()) { han[i] = se.top().first; achqisjoga[se.top().first]++; achqisjoga[i]--; obshi++; } } ma = 0, qaq = 0; int hanind = 0; for (int i = 1; i <= n; i++) { qaq += achqisjoga[i]; if (ma < qaq) { ma = max(ma, qaq); hanind = i; } } for (int hh = 0; hh <= hanind; hh++) { lr[hh] = min(lr[hh], hanind); } for (int hh = 0; hh <= N; hh++) { achqisjoga[hh] = 0; } } cout << obshi - ma; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt = 1; //cin >> tt; while (tt--) { solve(); } return 0; }

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

prison.cpp: In function 'void solve()':
prison.cpp:38:15: warning: unused variable 'k' [-Wunused-variable]
   38 |     int n, d, k, t;
      |               ^
prison.cpp:84:28: warning: iteration 500010 invokes undefined behavior [-Waggressive-loop-optimizations]
   84 |             achqisjoga[hh] = 0;
      |             ~~~~~~~~~~~~~~~^~~
prison.cpp:82:29: note: within this loop
   82 |         for (int hh = 0; hh <= N; hh++)
      |                          ~~~^~~~
prison.cpp:84:28: warning: 'void* __builtin_memset(void*, int, long unsigned int)' forming offset [2000040, 2000043] is out of the bounds [0, 2000040] of object 'achqisjoga' with type 'int [500010]' [-Warray-bounds]
   84 |             achqisjoga[hh] = 0;
      |             ~~~~~~~~~~~~~~~^~~
prison.cpp:34:5: note: 'achqisjoga' declared here
   34 | int achqisjoga[N];
      |     ^~~~~~~~~~
#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...