제출 #143775

#제출 시각아이디문제언어결과실행 시간메모리
143775jwvg0425Arranging Shoes (IOI19_shoes)C++17
45 / 100
99 ms11512 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]) { useCount--; 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; }

컴파일 시 표준 에러 (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...