Submission #592909

# Submission time Handle Problem Language Result Execution time Memory
592909 2022-07-09T19:30:05 Z Sofiatpc Simple game (IZhO17_game) C++14
22 / 100
1000 ms 5432 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1000005;
int N,M, h[MAXN];
int marc[MAXN];

int main()
{
    cin>>N>>M;
    for(int i = 1; i <= N; i++)cin>>h[i];
    for(int i = 1; i <= N; i++)
    {
        if(i==N)
        {
            marc[h[i]]++;
            break;
        }
        int s = min(h[i],h[i+1]), f = max(h[i],h[i+1]);
        if(s==f)
        {
            marc[s]++;
            continue;
        }
        for(int k = s; k < f; k++)marc[k]++;
    }

    for(int m = 1; m <= M; m++)
    {
        int q; cin>>q;
        if(q==1)
        {
            int p,v; cin>>p>>v;

            if(p==N) marc[h[p]]--;
            else
            {
                int ls = min(h[p],h[p+1]), lf = max(h[p],h[p+1]);
                for(int k = ls; k < lf; k++)marc[k]--;

                int s = min(v,h[p+1]), f = max(v,h[p+1]);
                for(int k = s; k < f; k++)marc[k]++;
            }

            if(p!=1)
            {
                int ls = min(h[p],h[p-1]), lf = max(h[p],h[p-1]);
                for(int k = ls; k < lf; k++)marc[k]--;

                int s = min(v,h[p-1]), f = max(v,h[p-1]);
                for(int k = s; k < f; k++)marc[k]++;
            }
            h[p]=v;
        }
        else
        {
            int x; cin>>x;
            cout<<marc[x]<<"\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 462 ms 4196 KB Output is correct
3 Correct 495 ms 4128 KB Output is correct
4 Correct 461 ms 4180 KB Output is correct
5 Correct 488 ms 4220 KB Output is correct
6 Correct 471 ms 4180 KB Output is correct
7 Correct 482 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 462 ms 4196 KB Output is correct
3 Correct 495 ms 4128 KB Output is correct
4 Correct 461 ms 4180 KB Output is correct
5 Correct 488 ms 4220 KB Output is correct
6 Correct 471 ms 4180 KB Output is correct
7 Correct 482 ms 4180 KB Output is correct
8 Correct 172 ms 1680 KB Output is correct
9 Execution timed out 1079 ms 5432 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 462 ms 4196 KB Output is correct
3 Correct 495 ms 4128 KB Output is correct
4 Correct 461 ms 4180 KB Output is correct
5 Correct 488 ms 4220 KB Output is correct
6 Correct 471 ms 4180 KB Output is correct
7 Correct 482 ms 4180 KB Output is correct
8 Correct 172 ms 1680 KB Output is correct
9 Execution timed out 1079 ms 5432 KB Time limit exceeded
10 Halted 0 ms 0 KB -