답안 #125957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125957 2019-07-06T15:15:44 Z EntityIT Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 380 KB
#include<bits/stdc++.h>

using namespace std;

const int N = (int)1e5 + 5;
int n, x[N << 1], y[N << 1], cnt[2], z[N << 1];
long long ans;

int main () {
    scanf("%d", &n);
    for (int i = 1; i <= (n << 1); ++i) scanf("%d %d", x + i, y + i), z[i] = (i + 1) / 2;

    for (int i = 1; i <= (n << 1); ++i) {
        if (y[i] < 2) ans += 1 - y[i], ++cnt[0];
        else ans += y[i] - 2, ++cnt[1];
    }

    ans += abs(cnt[0] - cnt[1]) / 2;

    sort(x + 1, x + (n << 1) + 1);
    for (int i = 1; i <= (n << 1); ++i) ans += abs(x[i] - z[i]);

    printf("%lld", ans);

    return 0;
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:11:69: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= (n << 1); ++i) scanf("%d %d", x + i, y + i), z[i] = (i + 1) / 2;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 380 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 380 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 380 KB Output isn't correct
7 Halted 0 ms 0 KB -