Submission #247225

# Submission time Handle Problem Language Result Execution time Memory
247225 2020-07-11T08:13:07 Z uacoder123 Baloni (COCI15_baloni) C++14
0 / 100
2000 ms 99648 KB
     #include <bits/stdc++.h>
    using namespace std;
    #define F first
    #define S second
    #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
    #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) int(x.size())
    #define mp(i,a) make_pair(i,a)
    #define pb(a) push_back(a)
    #define bit(x,b) (x&(1LL<<b))
     
    typedef long long int lli;
    typedef pair <lli,lli> ii;
    typedef pair <lli,ii> iii;
    typedef vector <lli> vi;
    set<int> arr[1000001];
    int arr1[1000001],ch[1000001]={},c=0;
    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int test=1;
      for(;test>0;--test)
      {
        int n;
        cin>>n;
        for(int i=0;i<n;++i)
        {
          cin>>arr1[i];
          arr[arr1[i]].insert(i);
        }
        for(int i=0;i<n;++i)
        {
          if(ch[i]==0)
          {
            c++;
            int cur=arr1[i],in=i;
            ch[i]=1;
            while(cur!=1)
            {
              auto it=lower_bound(all(arr[cur-1]),in);
              if(it==arr[cur-1].end())
                break;
              else
              {
                in=(*it);
                cur--;
                ch[in]=1;
              }
            }
          }
        }
        cout<<c<<endl;
      }
      return(0);
    }
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 47352 KB Output isn't correct
2 Incorrect 35 ms 47488 KB Output isn't correct
3 Incorrect 37 ms 47488 KB Output isn't correct
4 Incorrect 34 ms 47608 KB Output isn't correct
5 Execution timed out 2081 ms 94328 KB Time limit exceeded
6 Execution timed out 2082 ms 99648 KB Time limit exceeded
7 Execution timed out 2089 ms 90488 KB Time limit exceeded
8 Execution timed out 2072 ms 89928 KB Time limit exceeded
9 Execution timed out 2074 ms 92500 KB Time limit exceeded
10 Execution timed out 2093 ms 94048 KB Time limit exceeded