Submission #494107

# Submission time Handle Problem Language Result Execution time Memory
494107 2021-12-14T11:15:53 Z stefantaga Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 74012 KB
#include <bits/stdc++.h>

using namespace std;
int n,m,v[1000005],st[1000005],dr[1000005],cost[1000005];
vector <int> ev[1000005];
int maxim[1000005],i,val[1000005],j,sol[1000005];
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n>>m;
    for (i=1;i<=n;i++)
    {
        cin>>v[i];
        val[i]=-v[i];
    }
    for (i=1;i<=m;i++)
    {
        cin>>st[i]>>dr[i]>>cost[i];
        ev[dr[i]].push_back(i);
    }
    for (i=1;i<=n;i++)
    {
        maxim[i]=0;
        for (j=i-1;j>=1;j--)
        {
            if (v[i]<v[j]&&val[j]<v[i])
            {
                val[j]=v[i];
            }
            maxim[j]=max(maxim[j+1],val[j]+v[j]);
        }
        for (j=0;j<ev[i].size();j++)
        {
            if (maxim[st[ev[i][j]]]<=cost[ev[i][j]])
            {
                sol[ev[i][j]]=1;
            }
        }
    }
    for (i=1;i<=m;i++)
    {
        cout<<sol[i]<<'\n';
    }
    return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (j=0;j<ev[i].size();j++)
      |                  ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB Output is correct
2 Correct 12 ms 23756 KB Output is correct
3 Correct 13 ms 23776 KB Output is correct
4 Correct 13 ms 23820 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 15 ms 23828 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 15 ms 23816 KB Output is correct
9 Correct 13 ms 23884 KB Output is correct
10 Correct 13 ms 23816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB Output is correct
2 Correct 12 ms 23756 KB Output is correct
3 Correct 13 ms 23776 KB Output is correct
4 Correct 13 ms 23820 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 15 ms 23828 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 15 ms 23816 KB Output is correct
9 Correct 13 ms 23884 KB Output is correct
10 Correct 13 ms 23816 KB Output is correct
11 Correct 17 ms 24032 KB Output is correct
12 Correct 58 ms 24016 KB Output is correct
13 Correct 58 ms 24224 KB Output is correct
14 Correct 67 ms 24140 KB Output is correct
15 Correct 67 ms 24212 KB Output is correct
16 Correct 63 ms 24156 KB Output is correct
17 Correct 46 ms 24136 KB Output is correct
18 Correct 58 ms 24076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 74012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3088 ms 30044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB Output is correct
2 Correct 12 ms 23756 KB Output is correct
3 Correct 13 ms 23776 KB Output is correct
4 Correct 13 ms 23820 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 15 ms 23828 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 15 ms 23816 KB Output is correct
9 Correct 13 ms 23884 KB Output is correct
10 Correct 13 ms 23816 KB Output is correct
11 Correct 17 ms 24032 KB Output is correct
12 Correct 58 ms 24016 KB Output is correct
13 Correct 58 ms 24224 KB Output is correct
14 Correct 67 ms 24140 KB Output is correct
15 Correct 67 ms 24212 KB Output is correct
16 Correct 63 ms 24156 KB Output is correct
17 Correct 46 ms 24136 KB Output is correct
18 Correct 58 ms 24076 KB Output is correct
19 Execution timed out 3057 ms 38640 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB Output is correct
2 Correct 12 ms 23756 KB Output is correct
3 Correct 13 ms 23776 KB Output is correct
4 Correct 13 ms 23820 KB Output is correct
5 Correct 13 ms 23756 KB Output is correct
6 Correct 15 ms 23828 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 15 ms 23816 KB Output is correct
9 Correct 13 ms 23884 KB Output is correct
10 Correct 13 ms 23816 KB Output is correct
11 Correct 17 ms 24032 KB Output is correct
12 Correct 58 ms 24016 KB Output is correct
13 Correct 58 ms 24224 KB Output is correct
14 Correct 67 ms 24140 KB Output is correct
15 Correct 67 ms 24212 KB Output is correct
16 Correct 63 ms 24156 KB Output is correct
17 Correct 46 ms 24136 KB Output is correct
18 Correct 58 ms 24076 KB Output is correct
19 Execution timed out 3064 ms 74012 KB Time limit exceeded
20 Halted 0 ms 0 KB -