Submission #100896

#TimeUsernameProblemLanguageResultExecution timeMemory
100896autumn_eelTelegraph (JOI16_telegraph)C++14
10 / 100
254 ms512 KiB
#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)

telegraph.cpp: In function 'int main()':
telegraph.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a[i],&c[i]);a[i]--;
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...