# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100896 | autumn_eel | Telegraph (JOI16_telegraph) | C++14 | 254 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int a[20],c[20];
int main(){
int n;cin>>n;
if(n>10)abort();
vector<int>v;
rep(i,n){
v.push_back(i);
}
rep(i,n){
scanf("%d%d",&a[i],&c[i]);a[i]--;
}
ll Min=LLONG_MAX;
do{
ll cnt=0;
rep(i,n){
if(v[(i+n-1)%n]!=a[v[i]])cnt+=c[v[i]];
}
Min=min(Min,cnt);
}while(next_permutation(v.begin(),v.end()));
cout<<Min<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |