Submission #775993

# Submission time Handle Problem Language Result Execution time Memory
775993 2023-07-07T08:12:33 Z gun_gan Coin Collecting (JOI19_ho_t4) C++17
0 / 100
1 ms 324 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 2e5 + 7;

int N;
int a[MX][3], b[MX];
ll ans = 0;
 
int main() {
      cin.tie(0); ios_base::sync_with_stdio(0);
 
      cin >> N;
      for(int i = 0; i < 2 * N; i++) {
            int x, y;
            cin >> x >> y;

            if(1 <= x && x <= N && 1 <= y && y <= 2) {
                  a[x][y]++;
            } else if(1 <= x && x <= N) {
                  if(y > 2) {
                        a[x][2]++;
                        ans += y - 2;
                  } else {
                        a[x][1]++;
                        ans += 1 - y;
                  }
            } else if(1 <= y && y <= 2) {
                  if(x < 1) {
                        a[1][y]++;
                        ans += 1 - x;
                  } else {
                        a[N][y]++;
                        ans += x - N;
                  }
            } else {
                  if(y > 2 && x < 1) {
                        a[1][2]++;
                        ans += 1 - x + y - 2;
                  } else if(y > 2 && x > N) {
                        a[N][2]++;
                        ans += x - N + y - 2;
                  } else if(y < 1 && x < 1) {
                        a[1][1]++;
                        ans += 1 - x + 1 - y;
                  } else {
                        a[N][1]++;
                        ans += x - N + 1 - y;
                  }
            }
      }

      int diff = 0, sum = 0;
      for(int i = 1; i <= N; i++) {
            diff += a[i][1];

            if(i < N) {
                  sum += a[i][1] + a[i][2];
                  ans += abs(sum - i * 2);
            }
      }

      ans += abs(diff - N);

      cout << ans << '\n';
      
}     
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -