# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68102 | 2018-08-15T22:58:17 Z | duality | JOIRIS (JOI16_joiris) | C++11 | 3 ms | 620 KB |
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vpii; int A[50]; vpii sol; int norm(int N,int K) { int i; while (1) { for (i = 0; i < N; i++) { if (A[i] >= K) break; } if (i < N) { int m = 99; for (i = 0; i < N; i++) { if (A[i] == 0) { sol.pb(mp(1,i+1)); A[i] += K; } m = min(m,A[i]); } for (i = 0; i < N; i++) A[i] -= m; } else break; } return 0; } int diff[60]; int main() { int i; int N,K; scanf("%d %d",&N,&K); for (i = 0; i < N; i++) scanf("%d",&A[i]); int j; norm(N,K); for (i = 0; i <= N; i++) { if (i == 0) diff[i] = -A[i]; else if (i == N) diff[i] = A[N-1]; else diff[i] = A[i-1]-A[i]; } for (i = 0; i < K; i++) { int s = 0; for (j = i; j <= N; j += K) s += diff[j]; s %= K; if (s != 0) break; } if (i < K) { printf("-1\n"); return 0; } for (i = 0; i <= N-K; i++) { int m = 0; for (j = i; j < i+K; j++) m = max(m,A[j]); int x = (diff[i]+K) % K; for (j = 0; j < x; j++) sol.pb(mp(2,i+1)); diff[i+K] += diff[i]; m += x; for (j = 0; j < N; j++) { if ((j < i) || (j >= i+K)) { while (A[j] < m) sol.pb(mp(1,j+1)),A[j] += K; } else A[j] += x; } m = 1e9; for (j = 0; j < N; j++) m = min(m,A[j]); for (j = 0; j < N; j++) A[j] -= m; norm(N,K); } printf("%d\n",sol.size()); for (i = 0; i < sol.size(); i++) printf("%d %d\n",sol[i].first,sol[i].second); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 2 ms | 408 KB | Output is correct |
5 | Correct | 3 ms | 456 KB | Output is correct |
6 | Correct | 3 ms | 456 KB | Output is correct |
7 | Correct | 2 ms | 456 KB | Output is correct |
8 | Correct | 2 ms | 456 KB | Output is correct |
9 | Correct | 2 ms | 524 KB | Output is correct |
10 | Correct | 3 ms | 524 KB | Output is correct |
11 | Correct | 3 ms | 544 KB | Output is correct |
12 | Correct | 3 ms | 544 KB | Output is correct |
13 | Correct | 2 ms | 544 KB | Output is correct |
14 | Correct | 2 ms | 544 KB | Output is correct |
15 | Correct | 2 ms | 544 KB | Output is correct |
16 | Incorrect | 3 ms | 620 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | Output is correct |
2 | Incorrect | 2 ms | 620 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 2 ms | 408 KB | Output is correct |
5 | Correct | 3 ms | 456 KB | Output is correct |
6 | Correct | 3 ms | 456 KB | Output is correct |
7 | Correct | 2 ms | 456 KB | Output is correct |
8 | Correct | 2 ms | 456 KB | Output is correct |
9 | Correct | 2 ms | 524 KB | Output is correct |
10 | Correct | 3 ms | 524 KB | Output is correct |
11 | Correct | 3 ms | 544 KB | Output is correct |
12 | Correct | 3 ms | 544 KB | Output is correct |
13 | Correct | 2 ms | 544 KB | Output is correct |
14 | Correct | 2 ms | 544 KB | Output is correct |
15 | Correct | 2 ms | 544 KB | Output is correct |
16 | Incorrect | 3 ms | 620 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 2 ms | 408 KB | Output is correct |
5 | Correct | 3 ms | 456 KB | Output is correct |
6 | Correct | 3 ms | 456 KB | Output is correct |
7 | Correct | 2 ms | 456 KB | Output is correct |
8 | Correct | 2 ms | 456 KB | Output is correct |
9 | Correct | 2 ms | 524 KB | Output is correct |
10 | Correct | 3 ms | 524 KB | Output is correct |
11 | Correct | 3 ms | 544 KB | Output is correct |
12 | Correct | 3 ms | 544 KB | Output is correct |
13 | Correct | 2 ms | 544 KB | Output is correct |
14 | Correct | 2 ms | 544 KB | Output is correct |
15 | Correct | 2 ms | 544 KB | Output is correct |
16 | Incorrect | 3 ms | 620 KB | Output isn't correct |