Submission #404655

#TimeUsernameProblemLanguageResultExecution timeMemory
404655sadPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; int k,n;ll re=0; map<ll,int>st,en; ll no=0,fin=0; vector<int>v; int main() { cin>>k>>n;ll w=0; for(int i=0;i<n;i++) { char a,b; int x,y; cin>>a>>x>>b>>y; re+=abs(x-y); if(a==b)continue; re-=(abs(x-y)); re++; if(x>y)swap(x,y); v.pb(x);v.pb(y); st[x]++; st[y];no++; en[y]++;w+=x; } ll mn=0; ll last=0; sort(v.begin(),v.end()); ll r=0;int q=0; for(int j=0;j<v.size();j++) { ll zz=0; for(int i=0;i<v.size();i++) { zz+=abs(v[i]-v[j]); } mn=min(mn,zz); zz=0; /* w+=fin*(it.fi-last); w-=no*(it.fi-last); fin+=en[it.fi]; no-=st[it.fi]; mn=min(mn,w);last=it.fi; */ } if(v.size()==0)mn=0; re+=mn; cout<<re; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int j=0;j<v.size();j++)
      |                 ~^~~~~~~~~
bridge.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i=0;i<v.size();i++)
      |                     ~^~~~~~~~~
bridge.cpp:30:8: warning: unused variable 'last' [-Wunused-variable]
   30 |     ll last=0;
      |        ^~~~
bridge.cpp:32:8: warning: unused variable 'r' [-Wunused-variable]
   32 |     ll r=0;int q=0;
      |        ^
bridge.cpp:32:16: warning: unused variable 'q' [-Wunused-variable]
   32 |     ll r=0;int q=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...