Submission #1172545


Source Code Expand

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

typedef long long ll;

int a[100001];
int m[100001];

int main(){
	int n;
	
	cin >> n;
	
	REP(i,n){
		scanf("%d", &a[i]);
		m[i] = a[i];
	}
	
	sort(m,m+n);
	
	int ans = 0;
	int sum = 0;
	int k = 0;
	
	REP(i,n){
		sum++;
		REP(j,n){
			if (m[k] == a[j]){
				k++;
				ans = sum;
			}
		}
	}
	
	if (m[n-1] == a[0]) ans--;
	
	cout << ans << endl;
	
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   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 × 25
WA × 1
AC × 19
TLE × 4
AC × 37
WA × 1
TLE × 10
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 WA 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 821 ms 512 KB
50_rand_02.txt TLE 2103 ms 768 KB
50_rand_03.txt TLE 2103 ms 768 KB
50_rand_04.txt AC 1899 ms 640 KB
50_rand_05.txt AC 310 ms 384 KB
50_rand_06.txt AC 1 ms 256 KB
50_rand_07.txt AC 77 ms 384 KB
50_rand_08.txt AC 1963 ms 640 KB
60_perm_01.txt AC 824 ms 512 KB
60_perm_02.txt TLE 2103 ms 768 KB
60_perm_03.txt TLE 2103 ms 768 KB
60_perm_04.txt AC 1903 ms 640 KB
60_perm_05.txt AC 311 ms 384 KB
60_perm_06.txt AC 1 ms 256 KB
60_perm_07.txt AC 77 ms 384 KB
60_perm_08.txt AC 1964 ms 640 KB
70_hand_01.txt TLE 2103 ms 1024 KB
70_hand_02.txt TLE 2103 ms 1024 KB
70_hand_03.txt TLE 2103 ms 1024 KB
70_hand_04.txt TLE 2103 ms 1024 KB
70_hand_05.txt TLE 2103 ms 1024 KB
70_hand_06.txt TLE 2103 ms 1024 KB