Submission #43023

# Submission time Handle Problem Language Result Execution time Memory
43023 2018-03-08T06:38:05 Z milmillin Editor (BOI15_edi) C++14
15 / 100
95 ms 2420 KB
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> undo;
vector<int> states;

bool isActive() {
	return undo.size()%2==0;
}

int main () {
	int n;
	scanf("%d", &n);
	states.push_back(0);
	int x;
	bool tmp;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x > 0) {
			if (!isActive()) states.pop_back();
			undo.clear();
			states.push_back(x);
		} else {
			//if (states.back() != 0) {
			x = -x;
			tmp = isActive();
			while (!undo.empty() && (undo.size()%2==tmp || undo.back() >= x)) undo.pop_back();
			if (!tmp&&undo.empty()&&states.size()>1) states.pop_back();
			if (states.back()!=0) undo.push_back(x);
			//}
		}
		//for (auto j : states) printf("%d ", j);
		//printf("\n");
		//for (auto j : undo) printf("%d ", j);
		//printf("\n");
		printf("%d\n", (isActive())?states.back():states[states.size()-2]);
	}
	return 0;
}

Compilation message

edi.cpp: In function 'int main()':
edi.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
edi.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 95 ms 2272 KB Output is correct
2 Correct 83 ms 2420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 2420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -