Submission #1172479


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 main() {
	int n;
	int a[112345];
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	pii s[112345];
	REP(i, n) s[i] = pii(a[i], i);
	sort(s, s + n);
	
	int ans = 0, pos = 0;
	bool move = false;
	
	REP(i, n) {
		if (s[i].second < pos) {
			ans++;
			pos = s[i].second;
		}
		else {
			if (pos == s[i].second) {
				if (pos = n - 1) ans++;
				pos = (pos + 1) % n;
			}
			else {
				pos = s[i].second;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User tkmst201
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1084 Byte
Status WA
Exec Time 19 ms
Memory 1536 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26: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 0 / 20 0 / 10 0 / 70
Status
AC × 4
AC × 10
WA × 16
AC × 8
WA × 15
AC × 14
WA × 34
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 2 ms 1152 KB
00_example_02.txt AC 2 ms 1152 KB
00_example_03.txt AC 2 ms 1152 KB
00_example_04.txt AC 2 ms 1152 KB
10_rand_01.txt WA 2 ms 1152 KB
10_rand_02.txt WA 2 ms 1152 KB
10_rand_03.txt WA 2 ms 1152 KB
10_rand_04.txt AC 2 ms 1152 KB
10_rand_05.txt WA 2 ms 1152 KB
10_rand_06.txt WA 2 ms 1152 KB
10_rand_07.txt WA 2 ms 1152 KB
10_rand_08.txt WA 2 ms 1152 KB
20_perm_01.txt WA 2 ms 1152 KB
20_perm_02.txt WA 2 ms 1152 KB
20_perm_03.txt WA 2 ms 1152 KB
20_perm_04.txt WA 2 ms 1152 KB
20_perm_05.txt AC 2 ms 1152 KB
20_perm_06.txt WA 2 ms 1152 KB
20_perm_07.txt WA 2 ms 1152 KB
20_perm_08.txt WA 2 ms 1152 KB
30_hand_01.txt AC 2 ms 1152 KB
30_hand_02.txt AC 2 ms 1152 KB
30_hand_03.txt AC 2 ms 1152 KB
30_hand_04.txt AC 2 ms 1152 KB
30_hand_05.txt WA 2 ms 1152 KB
30_hand_06.txt WA 2 ms 1152 KB
50_rand_01.txt WA 8 ms 1280 KB
50_rand_02.txt WA 13 ms 1408 KB
50_rand_03.txt WA 13 ms 1408 KB
50_rand_04.txt WA 11 ms 1280 KB
50_rand_05.txt WA 5 ms 1152 KB
50_rand_06.txt WA 2 ms 1152 KB
50_rand_07.txt WA 3 ms 1152 KB
50_rand_08.txt WA 11 ms 1280 KB
60_perm_01.txt WA 7 ms 1280 KB
60_perm_02.txt WA 13 ms 1408 KB
60_perm_03.txt WA 13 ms 1408 KB
60_perm_04.txt WA 10 ms 1280 KB
60_perm_05.txt WA 5 ms 1152 KB
60_perm_06.txt WA 2 ms 1152 KB
60_perm_07.txt WA 3 ms 1152 KB
60_perm_08.txt WA 11 ms 1280 KB
70_hand_01.txt AC 13 ms 1536 KB
70_hand_02.txt AC 12 ms 1536 KB
70_hand_03.txt AC 12 ms 1536 KB
70_hand_04.txt AC 12 ms 1536 KB
70_hand_05.txt WA 19 ms 1536 KB
70_hand_06.txt WA 19 ms 1536 KB