Submission #968806

#TimeUsernameProblemLanguageResultExecution timeMemory
968806batsukh2006Palembang Bridges (APIO15_bridge)C++17
22 / 100
32 ms4308 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> #include<numeric> #include<tuple> #include<bitset> using namespace std; #define MOD 1000000007 #define int long long #define ss second #define ff first #define endl '\n' typedef pair<int,int> pp; signed main(){ // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k,n; cin>>k>>n; int ans=0; vector<int> v; for(int i=1; i<=n; i++){ int s,t; char p,q; cin>>p>>s>>q>>t; if(p==q){ ans+=abs(s-t); }else{ ans++; v.push_back(s); v.push_back(t); } } int mid=v.size()/2; sort(v.begin(),v.end()); for(int i=0; i<v.size(); i++){ ans+=abs(v[mid]-v[i]); } cout<<ans; return 0; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:54:19: 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]
   54 |     for(int 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...