Submission #1172497


Source Code Expand

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int n;
int a[112345];
set<int> ss[112345];
pii p[112345];

int main() {
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	REP(i, n) {
		p[i] = pii(a[i], i);
		ss[a[i]].insert(i);
	}
	
	int ans = 0, pos = 0;
	
	
	REP(i, 112345) {
		while (!ss[i].empty()) {
			set<int>::iterator it = ss[i].lower_bound(pos);
			
			if (it == ss[i].end()) {
				it = ss[i].lower_bound(0);
				
				ans++;
			}
			
			pos = *it;
			ss[i].erase(it);
		}
	}
	
	if (pos != 0) ans++;
	
	cout << ans << endl;
	
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  REP(i, n) scanf("%d", a + i);
                              ^

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 5504 KB
00_example_02.txt AC 3 ms 5504 KB
00_example_03.txt AC 3 ms 5504 KB
00_example_04.txt AC 3 ms 5504 KB
10_rand_01.txt AC 3 ms 5504 KB
10_rand_02.txt AC 3 ms 5504 KB
10_rand_03.txt AC 3 ms 5504 KB
10_rand_04.txt AC 3 ms 5504 KB
10_rand_05.txt AC 3 ms 5504 KB
10_rand_06.txt AC 3 ms 5504 KB
10_rand_07.txt AC 3 ms 5504 KB
10_rand_08.txt AC 3 ms 5504 KB
20_perm_01.txt AC 3 ms 5504 KB
20_perm_02.txt AC 3 ms 5504 KB
20_perm_03.txt AC 3 ms 5504 KB
20_perm_04.txt AC 3 ms 5504 KB
20_perm_05.txt AC 3 ms 5504 KB
20_perm_06.txt AC 3 ms 5504 KB
20_perm_07.txt AC 3 ms 5504 KB
20_perm_08.txt AC 3 ms 5504 KB
30_hand_01.txt AC 3 ms 5504 KB
30_hand_02.txt AC 3 ms 5504 KB
30_hand_03.txt AC 3 ms 5504 KB
30_hand_04.txt AC 4 ms 5504 KB
30_hand_05.txt AC 3 ms 5504 KB
30_hand_06.txt AC 3 ms 5504 KB
50_rand_01.txt AC 13 ms 7552 KB
50_rand_02.txt AC 23 ms 9472 KB
50_rand_03.txt AC 23 ms 9600 KB
50_rand_04.txt AC 18 ms 8704 KB
50_rand_05.txt AC 9 ms 6784 KB
50_rand_06.txt AC 4 ms 5504 KB
50_rand_07.txt AC 6 ms 6144 KB
50_rand_08.txt AC 18 ms 8704 KB
60_perm_01.txt AC 11 ms 7552 KB
60_perm_02.txt AC 17 ms 9472 KB
60_perm_03.txt AC 17 ms 9600 KB
60_perm_04.txt AC 14 ms 8704 KB
60_perm_05.txt AC 7 ms 6784 KB
60_perm_06.txt AC 4 ms 5504 KB
60_perm_07.txt AC 6 ms 6144 KB
60_perm_08.txt AC 15 ms 8704 KB
70_hand_01.txt AC 20 ms 11392 KB
70_hand_02.txt AC 21 ms 11392 KB
70_hand_03.txt AC 36 ms 11392 KB
70_hand_04.txt AC 33 ms 11392 KB
70_hand_05.txt AC 26 ms 11392 KB
70_hand_06.txt AC 37 ms 11392 KB