Submission #57152

# Submission time Handle Problem Language Result Execution time Memory
57152 2018-07-14T07:19:51 Z 윤교준(#1654) JOIRIS (JOI16_joiris) C++11
0 / 100
1000 ms 432 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void fuk() { puts("-1"); exit(0); }

vector<pii> Ans;

int A[55], B[55];

int N, L;

int main() {
	cin >> N >> L;
	for(int i = 1; i <= N; i++) cin >> A[i];

	for(int i = 2; i <= N; i++) {
		for(; A[i] < A[i-1];) {
			Ans.eb(1, i);
			A[i] += L;
		}
	}
	for(int i = 1; i <= N; i++) B[i] = A[i];

	for(int h = 1; h <= A[N]; h++) {
		int i = N; for(; i && h <= A[i]; i--);
		for(i = i+1 - L; 1 <= i; i -= L) {
			Ans.eb(2, i);
			for(int j = i; j < i+L; j++) B[j]++;
		}
	}

	for(int i = 1; i <= N-L; i++) {
		for(; B[i] < B[N];) {
			Ans.eb(1, i);
			B[i] += L;
		}
	}

	for(; L < N && B[N] < B[1];) {
		Ans.eb(2, N-L+1);
		for(int i = N-L+1; i <= N; i++) B[i]++;
	}

	for(int i = 2; i <= N; i++)
		if(B[1] != B[i]) fuk();

	printf("%d\n", sz(Ans));
	for(auto &e : Ans) printf("%d %d\n", e.first, e.second);

	{
		int tmp = 0;
		for(int i = 0; i < 50000; i++) for(int j = 0; j < 80000; j++)
			upmin(tmp, i/40000*j + 55);
		if(tmp) puts("YEAH");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Execution timed out 1035 ms 432 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Execution timed out 1035 ms 432 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Execution timed out 1035 ms 432 KB Time limit exceeded
5 Halted 0 ms 0 KB -