제출 #72146

#제출 시각아이디문제언어결과실행 시간메모리
72146@younha_holic (#118)박스런 (FXCUP3_box)C++17
17 / 100
1086 ms1000 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1<<19; int n, a[maxn], b[maxn]; typedef pair<int, int> pint; #define x first #define y second pint dq[maxn]; int y, z; void xfill(int s, int e, int l, int r) { if (s>e) return; int m = (s+e)/2, k = max(m, l); y = 0, z = 0; for (int i=k-m+1; i<=k; i++) { while (y<z and dq[z-1].x < a[i]) z--; dq[z++] = pint(a[i], i); } while (k+1<=r) { pint x = dq[y]; if (a[k+1] > x.x) break; k++; if (dq[y].y < k-m+1) y++; while (y<z and dq[z-1].x < a[k]) z--; dq[z++] = pint(a[k], k); } if (k>r) k = r; b[m] = k; if (s<e) { xfill(s, m-1, l, k); xfill(m+1, e, k, r); } } int main() { cin >> n; for (int i=1; i<=n; i++) scanf("%d", &a[i]); xfill(1, n, 1, n); for (int i=1; i<=n; i++) { if (b[i] == n) printf("-1 "); else printf("%d ", b[i] - i + 1); } }

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

box.cpp: In function 'int main()':
box.cpp:42:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1; i<=n; i++) scanf("%d", &a[i]);
                           ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...