Submission #987569

# Submission time Handle Problem Language Result Execution time Memory
987569 2024-05-23T05:10:35 Z cig32 Fruits (NOI22_fruits) C++17
0 / 100
72 ms 17316 KB
#include "bits/stdc++.h"
#define int long long
using namespace std;
const int MAXN = 4e5 + 10;
int ps[2010][2010];
int freq(int l, int r, int lb, int ub) {
  return ps[r][ub] - ps[l-1][ub] - ps[r][lb-1] + ps[l-1][lb-1];
}
void solve(int tc) {
  int n;
  cin >> n;
  int a[n+1], c[n+1];
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++) cin >> c[i];

    int p[n+1];
    for(int i=1; i<=n; i++) p[i] = 0;
    for(int i=1; i<=n; i++) {
      if(a[i] > 0) p[a[i]] = 1;
    }
    int mx = 0;
    queue<int> q;
    for(int i=1; i<=n; i++) {
      if(p[i] == 0) q.push(i);
    }
    int ans = 0;
    for(int i=1; i<=n; i++) {
      if(a[i] == -1) {
        while(q.size() && q.front() < mx) {
          q.pop();
        }
        if(q.size()) {
          mx = q.front();
          q.pop();
          ans++;
        }
      }
      else {
        if(a[i] > mx) {
          mx = a[i];
          ans++;
        }
      }
      cout << ans << " \n"[i == n];
    }
    return;
  
  
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t=1; //cin>>t;
  for(int i=1; i<=t; i++) solve(i);
}
/*
g++ T2443.cpp -std=c++17 -O2 -o T2443
./T2443 < input.txt


g++ gen.cpp -std=c++17 -O2 -o gen
g++ checker.cpp -std=c++17 -O2 -o checker
g++ T2443.cpp -std=c++17 -O2 -o T2443
g++ T2443_brute.cpp -std=c++17 -O2 -o T2443_brute
for((i=1;; ++i)); do
  ./gen $i > input.txt
  ./T2443 < input.txt > output.txt
  ./T2443_brute < input.txt > answer.txt
  ./checker
  echo "Passed test: " $i
done
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 17316 KB Output is correct
2 Incorrect 72 ms 15924 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -