Submission #440826

# Submission time Handle Problem Language Result Execution time Memory
440826 2021-07-03T10:25:28 Z MrDeboo Exam (eJOI20_exam) C++17
0 / 100
21 ms 332 KB
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define endl '\n'
using namespace std;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    bool bol=true;
    pair<int,int>pr[n];
    for(int i=0;i<n;i++){
        cin>>pr[i].first;
        if(i>0&&pr[i].first<=pr[i-1].second)bol=false;
    }
    for(int i=0;i<n;i++){
        cin>>pr[i].second;
    }
    if(!bol){
        int ans=0,z=0,b=pr[0].second;
        bool bl=false;
        for(int i=0;i<n;i++){
            if(pr[i].first==b)bl=true;
            if(pr[i].first<=b&&i!=n-1)z++;
            else if(bl){
                ans+=z+(pr[i].first<=b?1:0);
                z=0;
            }
            else z=0;
        }
        cout<<ans;
    }
    else{
        bool m[n];
        memset(m,false,sizeof(m));
        for(int i=n-1;i>=0;i--){
            int a=0,b=0,z=n;
            for(int w=i-1;w>=0;w--){
                if(m[w])b++;
                if(pr[w].second==pr[i].first)a++;
                if(a>b)z=w;
            }
            for(int w=i-1;w>=z;w--){
                if(pr[w].second==pr[i].first)m[w]=true;
                else m[w]=false;
            }
            if(pr[i].first==pr[i].second)m[i]=true;
        }
        int ans=0;
        for(int i=0;i<n;i++){
            if(m[i])ans++;
        }
        cout<<ans;
    }
}
//5 1 1 1 6 5
//5 5 6 5 6

Compilation message

In file included from /usr/include/string.h:495,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from exam.cpp:1:
In function 'void* memset(void*, int, size_t)',
    inlined from 'int main()' at exam.cpp:35:15:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: warning: 'void* __builtin_memset(void*, int, long unsigned int)' specified size between 9223372036854775808 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct