Submission #143774

#TimeUsernameProblemLanguageResultExecution timeMemory
143774jwvg0425Arranging Shoes (IOI19_shoes)C++17
25 / 100
98 ms11384 KiB
#include "shoes.h" #include <set> long long count_swaps(std::vector<int> s) { std::set<int> minus; std::set<int> plus; std::vector<bool> used(s.size(), false); long long ans = 0; long long useCount = 0; for (int i = 0; i < s.size(); i++) { if (s[i] > 0) plus.insert(i); else minus.insert(i); } for (int i = 0; i < s.size(); i++) { if (used[i]) continue; if (s[i] > 0) { int near = *minus.lower_bound(i); minus.erase(near); used[near] = true; ans += near - i - useCount; } else { int near = *plus.lower_bound(i); plus.erase(near); used[near] = true; ans += near - i - 1 - useCount; } useCount++; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:12:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++)
                     ~~^~~~~~~~~~
shoes.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int 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...