제출 #480780

#제출 시각아이디문제언어결과실행 시간메모리
480780duchung중앙값 배열 (balkan11_medians)C++17
100 / 100
48 ms2564 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n; int bit[N]; bool used[N]; void update(int idx , int val) { for (idx ; idx <= 2 * n - 1 ; idx += idx & -idx) bit[idx] += 1; } int get(int idx) { int ret = 0; for (idx ; idx >= 1 ; idx -= idx & -idx) ret += bit[idx]; return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; int pt1 = 1 , pt2 = 2 * n - 1; for (int sz = 1 ; sz <= 2 * n - 1 ; sz += 2) { int tmp; cin >> tmp; if (!used[tmp]) { used[tmp] = true; update(tmp , 1); cout << tmp << " "; } while(get(tmp - 1) < sz / 2) { while(used[pt1]) ++pt1; used[pt1] = true; update(pt1 , 1); cout << pt1 << " "; } while(get(2 * n - 1) - get(tmp) < sz / 2) { while(used[pt2]) --pt2; used[pt2] = true; update(pt2 , 1); cout << pt2 << " "; } } }

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

medians.cpp: In function 'void update(int, int)':
medians.cpp:12:10: warning: statement has no effect [-Wunused-value]
   12 |     for (idx ; idx <= 2 * n - 1 ; idx += idx & -idx) bit[idx] += 1;
      |          ^~~
medians.cpp: In function 'int get(int)':
medians.cpp:18:10: warning: statement has no effect [-Wunused-value]
   18 |     for (idx ; idx >= 1 ; idx -= idx & -idx) ret += bit[idx];
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...