Submission #257910

# Submission time Handle Problem Language Result Execution time Memory
257910 2020-08-05T04:12:04 Z 반딧불(#5055) Employment (JOI16_employment) C++17
30 / 100
341 ms 17880 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
int arr[200002];
vector<pair<int, int> > vec;
map<int, int> mp;
int cnt;

bool chk[200002];

int main(){
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++){
        scanf("%d", &arr[i]);
        vec.push_back(make_pair(arr[i], i));
    }
    sort(vec.begin(), vec.end());

    mp[1000000001] = 0;
    for(int i=n-1; i>=0; i--){
        int tx = vec[i].second, ty = vec[i].first;
        if(!chk[tx-1] && !chk[tx+1]) cnt++;
        else if(chk[tx-1] && chk[tx+1]) cnt--;
        chk[tx] = 1;
        mp[ty] = cnt;
    }

    while(q--){
        int qd;
        scanf("%d %d", &qd, &qd);
        auto it = mp.lower_bound(qd);
        printf("%d\n", it->second);
    }
}

Compilation message

employment.cpp: In function 'int main()':
employment.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
employment.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
employment.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &qd, &qd);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 16 ms 1152 KB Output is correct
5 Correct 33 ms 2680 KB Output is correct
6 Correct 53 ms 3044 KB Output is correct
7 Correct 87 ms 7020 KB Output is correct
8 Correct 115 ms 8168 KB Output is correct
9 Correct 211 ms 11624 KB Output is correct
10 Correct 200 ms 15344 KB Output is correct
11 Correct 256 ms 15204 KB Output is correct
12 Correct 341 ms 17204 KB Output is correct
13 Correct 321 ms 17508 KB Output is correct
14 Correct 293 ms 16996 KB Output is correct
15 Correct 292 ms 17452 KB Output is correct
16 Correct 328 ms 17636 KB Output is correct
17 Correct 327 ms 17636 KB Output is correct
18 Correct 337 ms 17764 KB Output is correct
19 Correct 291 ms 17764 KB Output is correct
20 Correct 302 ms 17880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -