제출 #924031

#제출 시각아이디문제언어결과실행 시간메모리
924031SunbaeStone Arranging 2 (JOI23_ho_t1)C++17
35 / 100
37 ms10808 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200005; int A[N], val[N], m; vector<int>C; int pos(int x){return lower_bound(C.begin(), C.end(), x) - C.begin();} int B[N]; vector<int> V[N]; bool cmp(int x, int y){return V[x].front() < V[y].front();} signed main(){ int n; scanf("%d", &n); for(int i = 0; i<n; ++i) scanf("%d", A+i), C.push_back(A[i]); sort(C.begin(), C.end()); C.resize(unique(C.begin(), C.end()) - C.begin()); m = C.size(); for(int i = 0; i<m; ++i) val[i] = C[i]; for(int i = 0; i<n; ++i) A[i] = pos(A[i]); for(int i = 0; i<n; ++i) V[A[i]].push_back(i); for(int i = 0; i<m; ++i) B[i] = i; sort(B, B+m, cmp); int Right = -1; for(int i = 0; i<m; ++i){ int x = B[i]; int l = max(Right+1, V[x].front()); int r = V[x].back(); if(l > r) continue; for(int j = l; j<=r; ++j) printf("%d\n", val[x]); Right = max(Right, r); } }

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

Main.cpp: In function 'int main()':
Main.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
Main.cpp:12:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  for(int i = 0; i<n; ++i) scanf("%d", A+i), C.push_back(A[i]);
      |                           ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...