Submission #607598

#TimeUsernameProblemLanguageResultExecution timeMemory
607598nyaruhodoArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms300 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long count_swaps(std::vector<int> s) { set<pair<ll,ll>> st; // val, pos ll cnt=0; for(ll i = 0;i < s.size();i++){ auto lb = st.lower_bound({-s[i],-1}); if(lb == st.end() || lb->first!=-s[i]){ st.insert({s[i],i}); continue; } auto p = *lb; st.erase(lb); cnt+=i-p.second-1; if(s[i]<0) cnt++; } return cnt; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:12:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(ll i = 0;i < s.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...