# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56965 | 2018-07-13T11:12:38 Z | 조민규(#2115) | JOIRIS (JOI16_joiris) | C++11 | 4 ms | 1036 KB |
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; int arr[60]; int cur[60]; int tmp[60]; int cnt[60]; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, l, i, j, k; scanf("%d%d", &n, &l); for(i = 1; i <= n; i++) scanf("%d", &arr[i]); for(i = 0; i < l; i++) { for(j = 1; j <= n; j++) { cur[j] = arr[j]; tmp[j] = (arr[j] + i) % l; } for(j = 1; j <= n - l + 1; j++) { cnt[j] = (l - tmp[j]) % l; for(k = j; k < j + l; k++) tmp[k] = (tmp[k] + cnt[j]) % l; } bool ok = 1; for(j = 1; j <= n; j++) { if(tmp[j]) { ok = 0; break; } } if(!ok) continue; vector<pair<int, int>> res; for(j = 1; j <= n - l + 1; j++) { for(k = 0; k < cnt[j]; k++) res.push_back({ 2, j }); int mx = 0; for(k = j; k < j + l; k++) mx = max(mx, cur[k]); int mn = 2 * l; for(k = 1; k <= n; k++) { if(j <= k && k < j + l) cur[k] += cnt[j]; else { while(cur[k] < mx + cnt[j]) { res.push_back({ 1, k }); cur[k] += l; } } mn = min(mn, cur[k]); } for(k = 1; k <= n; k++) { cur[k] -= mn; assert(cur[k] < l); } } int mx = 0; for(j = 1; j <= n; j++) mx = max(mx, cur[j]); for(j = 1; j <= n; j++) { while(cur[j] < mx) { res.push_back({ 1, j }); cur[j] += l; } } printf("%d\n", (int)res.size()); for(auto &p : res) printf("%d %d\n", p.first, p.second); return 0; } printf("-1\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 532 KB | Output is correct |
4 | Runtime error | 3 ms | 900 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 1036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 532 KB | Output is correct |
4 | Runtime error | 3 ms | 900 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 532 KB | Output is correct |
4 | Runtime error | 3 ms | 900 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |