Submission #303721

#TimeUsernameProblemLanguageResultExecution timeMemory
303721noob_c0deArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms304 KiB
#include<bits/stdc++.h> using namespace std; #define ar array bool ss(ar<int,2> a,ar<int,2> b) { if (a[0]==b[0]) return(a[1]<b[1]); return(a[0]<b[0]); } int count_swaps(vector<int> a) { vector<ar<int,2> > dg,am; for (int i=0;i<a.size();i++) { if (a[i]>0) dg.push_back({a[i],i}); else am.push_back({-a[i],i}); } sort(dg.begin(),dg.end(),ss); sort(am.begin(),am.end(),ss); int ans=0; for (int i=0;i<dg.size();i++) { if (dg[i][1]>am[i][1]) ans+=dg[i][1]-am[i][1]-1; else ans+=am[i][1]-dg[i][1]; } return(ans); }

Compilation message (stderr)

shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i=0;i<a.size();i++)
      |                  ~^~~~~~~~~
shoes.cpp:20:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i=0;i<dg.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...
#Verdict Execution timeMemoryGrader output
Fetching results...