Submission #878827

# Submission time Handle Problem Language Result Execution time Memory
878827 2023-11-25T09:45:42 Z niter Coin Collecting (JOI19_ho_t4) C++14
0 / 100
1000 ms 600 KB
#include <bits/stdc++.h>
#define pb push_back
#define ins isnert
#define pii pair<int,int>
#define ff first
#define ss second
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());

pii a[30], b[30];
int main(){
    int n, m;
    cin >> n;
    m = n << 1;
    loop(i,0,m) cin >> a[i].ff >> a[i].ss;
    loop(i,0,n){
        b[i] = {i + 1, 1};
        b[i + n] = {i + 1, 2};
    }
    sort(b, b + m);
    long long ans = (ll)(1e18), tmp;
    do{
        tmp = 0;
        loop(i,0,m){
            tmp += abs(a[i].ff - b[i].ff);
            tmp += abs(a[i].ss - b[i].ss);
        }
        ans = min(ans, tmp);
    }while(next_permutation(b, b + m));
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Execution timed out 1035 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Execution timed out 1035 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Execution timed out 1035 ms 600 KB Time limit exceeded
5 Halted 0 ms 0 KB -