Submission #396973

#TimeUsernameProblemLanguageResultExecution timeMemory
396973leinad2Palembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms256 KiB
#include<bits/stdc++.h> #define int long long 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:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      |      ^
bridge.cpp: In function 'int main()':
bridge.cpp:18:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     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...