Submission #1655298


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true

typedef long long ll;
typedef pair<int, int> ii;

struct NODE{
  int num;
  int a;
  bool operator<(const NODE r){
    if(a != r.a) return a < r.a;
    else return num < r.num;
  }
};

int main(){

	int n;
  cin >> n;
  vector<NODE> v(n);
  rep(i ,n) {
    v[i].num = i;
    cin >> v[i].a;
  }

  SORT(v);

  int ans = (v[n-1].num == 0 ? 0 : 1);
  int pos = -1;
  REP(i, 0, n){
    int maxi = -1;
    if(v[i].num < pos){
      ans++;
      int j;
      for(j = i; v[i].a == v[j].a; j++){
        if(v[j].num < pos) maxi = max(maxi, v[j].num);
      }
      i = j-1;
      pos = maxi;
    }
    else pos = v[i].num;
  }

  cout << ans << endl;

	return 0;
}

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User letter
Language C++14 (GCC 5.4.1)
Score 100
Code Size 934 Byte
Status AC
Exec Time 38 ms
Memory 1024 KB

Judge Result

Set Name Sample Small Permutation All
Score / Max Score 0 / 0 20 / 20 10 / 10 70 / 70
Status
AC × 4
AC × 26
AC × 23
AC × 48
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt
Small 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt
Permutation 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt, 50_rand_01.txt, 50_rand_02.txt, 50_rand_03.txt, 50_rand_04.txt, 50_rand_05.txt, 50_rand_06.txt, 50_rand_07.txt, 50_rand_08.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt, 70_hand_03.txt, 70_hand_04.txt, 70_hand_05.txt, 70_hand_06.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
00_example_04.txt AC 1 ms 256 KB
10_rand_01.txt AC 1 ms 256 KB
10_rand_02.txt AC 1 ms 256 KB
10_rand_03.txt AC 1 ms 256 KB
10_rand_04.txt AC 1 ms 256 KB
10_rand_05.txt AC 1 ms 256 KB
10_rand_06.txt AC 1 ms 256 KB
10_rand_07.txt AC 1 ms 256 KB
10_rand_08.txt AC 1 ms 256 KB
20_perm_01.txt AC 1 ms 256 KB
20_perm_02.txt AC 1 ms 256 KB
20_perm_03.txt AC 1 ms 256 KB
20_perm_04.txt AC 1 ms 256 KB
20_perm_05.txt AC 1 ms 256 KB
20_perm_06.txt AC 1 ms 256 KB
20_perm_07.txt AC 1 ms 256 KB
20_perm_08.txt AC 1 ms 256 KB
30_hand_01.txt AC 1 ms 256 KB
30_hand_02.txt AC 1 ms 256 KB
30_hand_03.txt AC 1 ms 256 KB
30_hand_04.txt AC 1 ms 256 KB
30_hand_05.txt AC 1 ms 256 KB
30_hand_06.txt AC 1 ms 256 KB
50_rand_01.txt AC 12 ms 512 KB
50_rand_02.txt AC 22 ms 768 KB
50_rand_03.txt AC 22 ms 768 KB
50_rand_04.txt AC 18 ms 640 KB
50_rand_05.txt AC 8 ms 384 KB
50_rand_06.txt AC 1 ms 256 KB
50_rand_07.txt AC 4 ms 384 KB
50_rand_08.txt AC 18 ms 640 KB
60_perm_01.txt AC 13 ms 512 KB
60_perm_02.txt AC 25 ms 768 KB
60_perm_03.txt AC 25 ms 768 KB
60_perm_04.txt AC 21 ms 640 KB
60_perm_05.txt AC 8 ms 384 KB
60_perm_06.txt AC 1 ms 256 KB
60_perm_07.txt AC 5 ms 384 KB
60_perm_08.txt AC 20 ms 640 KB
70_hand_01.txt AC 31 ms 1024 KB
70_hand_02.txt AC 31 ms 1024 KB
70_hand_03.txt AC 25 ms 1024 KB
70_hand_04.txt AC 25 ms 1024 KB
70_hand_05.txt AC 38 ms 1024 KB
70_hand_06.txt AC 31 ms 1024 KB