Submission #1732424


Source Code Expand

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

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, mn;
int a[100000 + 5]; 
vvi b(100000 + 5);

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        b[a[i]].push_back(i + 1);
    }
    int ans = 0;
    int now = INF;
    rep(i, 100000 + 2) {
        int m = b[i].size();
        if (m == 0) continue;
        int start = 0;
        rep(j, m) {
            if (now < b[i][j]) {
                start = j;
                break;
            }
        }
        rep2(j, start, start + m) {
            if (b[i][j % m] < now) ans++;
            now = b[i][j % m];
            //cout << now << endl;
        }
    }
    if (now == 1) ans--;
    cout << max(ans, 1LL) << endl;
}

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User roto_37
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1971 Byte
Status AC
Exec Time 21 ms
Memory 6528 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 3 ms 2560 KB
00_example_02.txt AC 3 ms 2560 KB
00_example_03.txt AC 3 ms 2560 KB
00_example_04.txt AC 3 ms 2560 KB
10_rand_01.txt AC 3 ms 2560 KB
10_rand_02.txt AC 3 ms 2560 KB
10_rand_03.txt AC 3 ms 2560 KB
10_rand_04.txt AC 3 ms 2560 KB
10_rand_05.txt AC 3 ms 2560 KB
10_rand_06.txt AC 3 ms 2560 KB
10_rand_07.txt AC 3 ms 2560 KB
10_rand_08.txt AC 2 ms 2560 KB
20_perm_01.txt AC 3 ms 2560 KB
20_perm_02.txt AC 3 ms 2560 KB
20_perm_03.txt AC 3 ms 2560 KB
20_perm_04.txt AC 3 ms 2560 KB
20_perm_05.txt AC 3 ms 2560 KB
20_perm_06.txt AC 3 ms 2560 KB
20_perm_07.txt AC 3 ms 2560 KB
20_perm_08.txt AC 2 ms 2560 KB
30_hand_01.txt AC 2 ms 2560 KB
30_hand_02.txt AC 3 ms 2560 KB
30_hand_03.txt AC 3 ms 2560 KB
30_hand_04.txt AC 2 ms 2560 KB
30_hand_05.txt AC 3 ms 2560 KB
30_hand_06.txt AC 2 ms 2560 KB
50_rand_01.txt AC 8 ms 3456 KB
50_rand_02.txt AC 13 ms 4224 KB
50_rand_03.txt AC 14 ms 4224 KB
50_rand_04.txt AC 11 ms 3840 KB
50_rand_05.txt AC 6 ms 3072 KB
50_rand_06.txt AC 3 ms 2560 KB
50_rand_07.txt AC 5 ms 2816 KB
50_rand_08.txt AC 11 ms 3840 KB
60_perm_01.txt AC 9 ms 3968 KB
60_perm_02.txt AC 14 ms 5248 KB
60_perm_03.txt AC 14 ms 5248 KB
60_perm_04.txt AC 12 ms 4736 KB
60_perm_05.txt AC 6 ms 3456 KB
60_perm_06.txt AC 3 ms 2560 KB
60_perm_07.txt AC 4 ms 3072 KB
60_perm_08.txt AC 12 ms 4736 KB
70_hand_01.txt AC 18 ms 6528 KB
70_hand_02.txt AC 18 ms 6528 KB
70_hand_03.txt AC 12 ms 4340 KB
70_hand_04.txt AC 12 ms 4344 KB
70_hand_05.txt AC 21 ms 5504 KB
70_hand_06.txt AC 13 ms 4480 KB