Submission #396972

#TimeUsernameProblemLanguageResultExecution timeMemory
396972leinad2Palembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms316 KiB
#include<bits/stdc++.h> using namespace std; char c, d; int a, b, n, i, j, k; long long ans; vector<int>v; main() { ios_base::sync_with_stdio(!cin.tie(NULL)); for(cin>>k>>n;i++<n;) { cin>>c>>a>>d>>b; if(c==d)ans+=(b-a); else ans++,v.push_back(a),v.push_back(b); } sort(v.begin(), v.end()); for(i=0;i<v.size();i++) { ans+=abs(v[i]-v[v.size()/2]); } cout<<ans; }

Compilation message (stderr)

bridge.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      |      ^
bridge.cpp: In function 'int main()':
bridge.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(i=0;i<v.size();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...
#Verdict Execution timeMemoryGrader output
Fetching results...