Submission #749556

# Submission time Handle Problem Language Result Execution time Memory
749556 2023-05-28T08:07:11 Z 반딧불(#9967) Fruits (NOI22_fruits) C++17
0 / 100
41 ms 2532 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int arr[400002];
bool taken[2002];
ll cost[2002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &arr[i]);
        if(arr[i] != -1) taken[arr[i]] = 1;
    }
    for(int i=1; i<=n; i++) scanf("%lld", &cost[i]);

    vector<int> v;
    for(int i=n; i>=1; i--) if(!taken[i]) v.push_back(i);
    int ans = 0, biggest = 0;
    for(int i=1; i<=n; i++){
        if(arr[i] == -1){
            while(!v.empty() && v.back() < biggest) v.pop_back();
            if(!v.empty()) ans++, biggest = v.back(), v.pop_back();
        }
        else{
            if(biggest < arr[i]) biggest = arr[i], ans++;
        }
        printf("%d ", ans);
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
Main.cpp:18:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     for(int i=1; i<=n; i++) scanf("%lld", &cost[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 2532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -