Codeforces 1143A The Doors

#define _CRT_SECURE_NO_WARNINGS
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

int n;
int temp[200000 + 5];

int main() {
	scanf("%d", &n);
	for (int i = 1;i <= n;++i) {
		scanf("%d", &temp[i]);
	}
	bool flag = false;
	int k = 0;
	if (temp[n] == 0) {
		for (int i = n;i >= 1;--i) {
			if (temp[i] == 1) {
				k = i;
				break;
			}
		}
	}
	else {
		for (int i = n;i >= 1;--i) {
			if (temp[i] == 0) {
				k = i;
				break;
			}
		}
	}
	printf("%d\n", k);
	//system("pause");
	return 0;
}

 

你可能感兴趣的:(ACM)