답안 #992776

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

        int cut = r+1, ok = 1;
        for (int j = 0; j < g.size() && ok; ++ j)
        {

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

        j = max(j, i);
        while(j < n && a[j] <= a[j+1])j ++;
        go[i] = j;
    }
    for (int 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:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int j = 0; j < g.size() && ok; ++ j)
      |                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2396 KB Output is correct
7 Correct 4 ms 2396 KB Output is correct
8 Correct 6 ms 2396 KB Output is correct
9 Correct 2 ms 2524 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2396 KB Output is correct
7 Correct 4 ms 2396 KB Output is correct
8 Correct 6 ms 2396 KB Output is correct
9 Correct 2 ms 2524 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 314 ms 10188 KB Output is correct
2 Correct 285 ms 10068 KB Output is correct
3 Correct 290 ms 10064 KB Output is correct
4 Correct 299 ms 10068 KB Output is correct
5 Correct 311 ms 10068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2396 KB Output is correct
7 Correct 4 ms 2396 KB Output is correct
8 Correct 6 ms 2396 KB Output is correct
9 Correct 2 ms 2524 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 4 ms 2396 KB Output is correct
7 Correct 4 ms 2396 KB Output is correct
8 Correct 6 ms 2396 KB Output is correct
9 Correct 2 ms 2524 KB Output is correct
10 Incorrect 4 ms 2396 KB Output isn't correct
11 Halted 0 ms 0 KB -