Submission #626540

#TimeUsernameProblemLanguageResultExecution timeMemory
626540TrunktyArranging Shoes (IOI19_shoes)C++14
45 / 100
74 ms69708 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll

#include "shoes.h"

ll ans,cnt;
deque<int> shoes[100005];

ll count_swaps(vector<int> s){
	for(ll i=0;i<s.size();i++){
		if(s[i]<0){
			cnt++;
			shoes[-s[i]].push_back(cnt);
			ans += abs(cnt*2LL-1LL-(i+1LL));
		}
	}
	cnt = 0;
	for(ll i=0;i<s.size();i++){
		if(s[i]>0){
			cnt++;
			int x = shoes[s[i]].front();
			shoes[s[i]].pop_front();
			ans += max(0LL,cnt-x);
		}
	}
	return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:12:14: 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++){
      |             ~^~~~~~~~~
shoes.cpp:20:14: 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]
   20 |  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...