Submission #106979

#TimeUsernameProblemLanguageResultExecution timeMemory
106979someone_aaPalembang Bridges (APIO15_bridge)C++17
8 / 100
2045 ms4692 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 100100; ll s[maxn], f[maxn], n, k; char szone[maxn], fzone[maxn]; int main() { cin>>k>>n; ll result = 0LL; vector<ll>v; for(int i=1;i<=n;i++) { cin>>szone[i]>>s[i]; cin>>fzone[i]>>f[i]; if(szone[i] == fzone[i]) result += abs(f[i] - s[i]); v.pb(s[i]); v.pb(f[i]); } if(k == 1) { ll mintemp = LLONG_MAX; for(int i:v) { ll temp = 0LL; for(int j=1;j<=n;j++) { if(szone[j] != fzone[j]) { temp += abs(s[j] - i) + abs(f[j] - i) + 1; } } mintemp = min(mintemp, temp); //cout<<i<<": "<<temp<<"\n"; } result += mintemp; cout<<result<<"\n"; return 0; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...