답안 #992781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992781 2024-06-05T07:20:58 Z n3rm1n Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
13 / 100
308 ms 18128 KB
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const long long MAXN = 1e6+10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
long long n, m;
long long a[MAXN], w;
long long l, r, k;
long long go[MAXN];
void read()
{
    cin >> n >> m;
    for (long long i = 1; i <= n; ++ i)
    {
        cin >> a[i];
    }
}
int marked[5005];
void solve5000()
{
    for (long long i = 1; i <= m; ++ i)
    {
        cin >> l >> r >> k;
        vector < pair < long long, long long > > g;
        for (long long j = l; j <= r; ++ j)
        {
            marked[j] = 0;
            g.push_back(make_pair(-a[j], j));
        }
        sort(g.begin(), g.end());

        long long cut = r+1, ok = 1;
        for (long long j = 0; j < g.size() && ok; ++ j)
        {
            if(marked[j])continue;
            for (long long id = g[j].second+1; id < cut && ok; ++ id)
            {
                if(a[id] - g[j].first <= k)
                {
                    marked[id] = 1;
                    continue;
                }
                else
                {
                    //cout << a[id] << " " << g[j].first << endl;
                    ok = 0;
                }
            }
            cut = g[j].second;
        }
        cout << ok << endl;
    }
}
void solve13()
{
    long long j = 1;
    for (long long i = 1; i <= n; ++ i)
    {

        j = max(j, i);
        while(j < n && a[j] <= a[j+1])j ++;
        go[i] = j;
    }
    for (long long i = 1; i <= m; ++ i)
    {
        cin >> l >> r >> k;
        if(go[l] < r)cout << 0 << endl;
        else cout << 1 << endl;

    }
}
int main()
{
    speed();

    read();
    if(n <= 5000)solve5000();
    else solve13();
    return 0;
}

Compilation message

sortbooks.cpp: In function 'void solve5000()':
sortbooks.cpp:39:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (long long j = 0; j < g.size() && ok; ++ j)
      |                               ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2532 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct
8 Correct 5 ms 2536 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2532 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct
8 Correct 5 ms 2536 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 301 ms 18128 KB Output is correct
2 Correct 295 ms 18000 KB Output is correct
3 Correct 304 ms 18000 KB Output is correct
4 Correct 308 ms 17928 KB Output is correct
5 Correct 293 ms 18004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 6952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2532 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct
8 Correct 5 ms 2536 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2532 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct
8 Correct 5 ms 2536 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -