# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
826909 | 2023-08-16T06:23:47 Z | 반딧불(#10373) | JOIRIS (JOI16_joiris) | C++17 | 1 ms | 388 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; int arr[52]; void subtask1(); void subtask2(); int main(){ scanf("%d %d", &n, &k); for(int i=1; i<=n; i++) scanf("%d", &arr[i]); if(k==2){ if(n%2==0) subtask1(); else subtask2(); } } vector<pair<int, int> > ans; void subtask1(){ if(accumulate(arr+1, arr+n+1, 0) % 2){ puts("-1"); exit(0); } for(int i=1; i<=n; i++){ while(arr[i] < arr[i-1]){ ans.push_back(make_pair(1, i)); arr[i] += 2; } } int minV = *min_element(arr+1, arr+n+1); for(int i=1; i<=n; i++) arr[i] -= minV; for(int i=1; i<n; i++){ int v = arr[i+1] - arr[i]; for(int j=i-1; j>=1; j-=2) for(int c=0; c<v; c++) ans.push_back(make_pair(2, j)); if(i%2==0) for(int j=i+1; j<=n; j++) arr[j] -= v; else for(int j=2; j<=i; j++) arr[j] += v; } int v = (arr[2] - arr[1]) / 2; for(int i=0; i<v; i++) ans.push_back(make_pair(1, 1)); printf("%d\n", (int)ans.size()); for(auto p: ans){ printf("%d %d\n", p.first, p.second); } } void subtask2(){ }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 304 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 388 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 308 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 304 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 388 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 308 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |
18 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 304 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 388 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 308 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |
18 | Halted | 0 ms | 0 KB | - |