답안 #1028163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028163 2024-07-19T14:43:39 Z snpmrnhlol Coin Collecting (JOI19_ho_t4) C++17
100 / 100
121 ms 8292 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5;
struct xy{
    ll x,y;
}v[N*2];
ll f[N][2];
ll f2[2];
int main(){
    ll n;
    ll ans = 0;
    cin>>n;
    for(ll i = 0;i < 2*n;i++){
        cin>>v[i].x>>v[i].y;
        v[i].x--;v[i].y--;
        if(0 > v[i].x || v[i].x > n - 1){
            ans+=min(abs(v[i].x - 0),abs(v[i].x - (n - 1)));
        }
        ans+=min(abs(v[i].y - 0),abs(v[i].y - 1));
        v[i].x = max(v[i].x,0ll);
        v[i].y = max(v[i].y,0ll);
        v[i].x = min(v[i].x,n - 1);
        v[i].y = min(v[i].y,1ll);
        f[v[i].x][v[i].y]++;
    }
    for(int i = 0;i < n;i++){
        f2[0]+=f[i][0];
        f2[1]+=f[i][1];
        f2[0]--;
        f2[1]--;
        if(f2[0] > 0 && f2[1] < 0){
            int x = min(f2[0],-f2[1]);
            f2[0]-=x;
            f2[1]+=x;
            ans+=x;
        }
        if(f2[0] < 0 && f2[1] > 0){
            int x = min(-f2[0],f2[1]);
            f2[0]+=x;
            f2[1]-=x;
            ans+=x;
        }
        if(i != n - 1){
            ans+=abs(f2[1]);
            ans+=abs(f2[0]);
        }
    }
    cout<<ans<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 344 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 3 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 456 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 452 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 436 KB Output is correct
59 Correct 2 ms 2396 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 464 KB Output is correct
63 Correct 1 ms 348 KB Output is correct
64 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 344 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 3 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 456 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 452 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 436 KB Output is correct
59 Correct 2 ms 2396 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 464 KB Output is correct
63 Correct 1 ms 348 KB Output is correct
64 Correct 2 ms 348 KB Output is correct
65 Correct 59 ms 6532 KB Output is correct
66 Correct 121 ms 8128 KB Output is correct
67 Correct 89 ms 8292 KB Output is correct
68 Correct 99 ms 8172 KB Output is correct
69 Correct 102 ms 8132 KB Output is correct
70 Correct 97 ms 8124 KB Output is correct
71 Correct 91 ms 8276 KB Output is correct
72 Correct 88 ms 6636 KB Output is correct
73 Correct 91 ms 6548 KB Output is correct
74 Correct 91 ms 6740 KB Output is correct
75 Correct 93 ms 6604 KB Output is correct
76 Correct 118 ms 6736 KB Output is correct
77 Correct 89 ms 6668 KB Output is correct
78 Correct 88 ms 6780 KB Output is correct
79 Correct 105 ms 6560 KB Output is correct
80 Correct 90 ms 6640 KB Output is correct
81 Correct 84 ms 6584 KB Output is correct
82 Correct 85 ms 6700 KB Output is correct
83 Correct 85 ms 6740 KB Output is correct
84 Correct 93 ms 6992 KB Output is correct
85 Correct 95 ms 6936 KB Output is correct
86 Correct 85 ms 8164 KB Output is correct
87 Correct 82 ms 8020 KB Output is correct
88 Correct 106 ms 8196 KB Output is correct
89 Correct 87 ms 8276 KB Output is correct
90 Correct 110 ms 8276 KB Output is correct
91 Correct 91 ms 8272 KB Output is correct
92 Correct 85 ms 8276 KB Output is correct
93 Correct 92 ms 8288 KB Output is correct
94 Correct 84 ms 8016 KB Output is correct
95 Correct 84 ms 8156 KB Output is correct
96 Correct 83 ms 7760 KB Output is correct
97 Correct 88 ms 7760 KB Output is correct
98 Correct 121 ms 7552 KB Output is correct
99 Correct 82 ms 8020 KB Output is correct
100 Correct 87 ms 7324 KB Output is correct
101 Correct 82 ms 7576 KB Output is correct
102 Correct 84 ms 7344 KB Output is correct
103 Correct 87 ms 7248 KB Output is correct