제출 #386234

#제출 시각아이디문제언어결과실행 시간메모리
386234patrikpavic2Money (IZhO17_money)C++17
0 / 100
1 ms368 KiB
#include <cstdio> #include <cstring> #include <vector> #include <algorithm> #define X first #define Y second #define PB push_back using namespace std; const int N = 1e6 + 500; int A[N], n, prv[N], nxt[N], sol; vector < pair < int, int > > v; void remove(int x){ prv[nxt[x]] = prv[x]; nxt[prv[x]] = nxt[x]; } int main(){ scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%d", A + i); v.PB({A[i], i}); } sort(v.begin(), v.end()); for(int i = 1;i <= n;i++) A[v[i - 1].Y] = i; nxt[0] = 0, prv[n + 1] = n; for(int i = 1;i <= n;i++){ prv[i] = i - 1; nxt[i] = i + 1; } for(int i = n - 1;i >= 0;i--){ int j = i; while(i >= 0 && A[i - 1] == prv[A[i]]) i--; for(int k = i;k <= j;k++) remove(A[k]); sol++; } printf("%d\n", sol); }

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

money.cpp: In function 'int main()':
money.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
money.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%d", A + i);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...