首页 > 其他分享 >CF1895B

CF1895B

时间:2023-11-06 21:22:34浏览次数:24  
标签:CF1895B fos read sum ww sim

analysis

观察性质,一定是将数组排序后,从 \(1 \sim n\) 为横坐标,从 \(n + 1 \sim n * 2\) 为纵坐标。所得距离应为横坐标之差的和和纵坐标之差的和。

核心代码。(手玩一下也能出来。)

    read(n);

    sum = 0;

    fos(i, 1, n * 2) read(a[i]);

    sort(a + 1, a + n * 2 + 1);

    fos(i, 2, n) sum += a[i] - a[i - 1];
    fos(i, n + 2, n * 2) sum += a[i] - a[i - 1];

    ww(sum), wl;
    fos(i, 1, n) ww(a[i]), ws, ww(a[2 * n - i + 1]), wl;

标签:CF1895B,fos,read,sum,ww,sim
From: https://www.cnblogs.com/carp-oier/p/CF1895B.html

相关文章