Submission #763423

#TimeUsernameProblemLanguageResultExecution timeMemory
763423KN200711Money (IZhO17_money)C++14
0 / 100
1 ms340 KiB
# include <bits/stdc++.h> using namespace std; const int MXN = 1e6; int fen[1000001]; void add(int a, int c) { while(a <= MXN) { fen[a] += c; a += a&(-a); } return; } int qry(int a) { int res = 0; while(a > 0) { res += fen[a]; a -= a&(-a); } return res; } int main() { int N; scanf("%d", &N); vector<int> arr(N); for(int i=0;i<N;i++) scanf("%d", &arr[i]); for(int i=1;i<=N;i++) { add(i, 1); } int ans = 0; for(int i=N-1;i>=0;i--) { int nw = i; int ls = qry(arr[i]); i--; while(i >= 0 && qry(arr[i]) == ls - 1) { i--; ls--; } ans++; i++; for(int c=i;c<=nw;c++) add(arr[c], -1); } printf("%d\n", ans); }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
money.cpp:29:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  for(int i=0;i<N;i++) scanf("%d", &arr[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...