Submission #425899

#TimeUsernameProblemLanguageResultExecution timeMemory
425899arayiWiring (IOI17_wiring)C++17
13 / 100
41 ms5100 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; #define lli long long #define ad push_back #define MP make_pair #define sc second #define fr first const int N = 1e6 + 30; const lli mod = 1e17; int n, m; lli dp[N], sum[N]; vector<pair<int, int> > a; lli s(int l, int r) { lli ret = sum[r]; if(l) ret -= sum[l - 1]; return ret; } lli sm(int i1, int i2, int l) { lli sum1 = s(i1, l), sum2 = s(l + 1, i2); lli s1 = l-i1+1, s2=i2-l; if(s1 > s2) sum2 += (s1-s2) * a[l+1].fr; else sum1 += (s2-s1) * a[l].fr; return sum2 - sum1; } long long min_total_length(vector<int> r, vector<int> b) { n=r.size(), m=b.size(); for(auto p : r) a.ad(MP(p, 0)); for(auto p : b) a.ad(MP(p, 1)); sort(a.begin(), a.end()); for (int i = 0; i < a.size(); i++) { sum[i]=a[i].fr; if(i) sum[i] += sum[i-1]; } return sm(0, a.size() - 1, r.size() - 1); int i; for (i = 0; i < a.size(); i++) { dp[i] = mod; if(a[i].sc != a[i+1].sc) break; } int l = i, i1 = i; lli sm = 0; i++; for (; i < a.size(); i++) { if(a[i].sc != a[i-1].sc) i1=l=i-1,sm=0; while (i1 > 0 && a[i1].sc == a[i1-1].sc) { } } }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for (int i = 0; i < a.size(); i++)
      |                  ~~^~~~~~~~~~
wiring.cpp:44:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (i = 0; i < a.size(); i++)
      |              ~~^~~~~~~~~~
wiring.cpp:52:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (; i < a.size(); i++)
      |         ~~^~~~~~~~~~
wiring.cpp:50:6: warning: variable 'sm' set but not used [-Wunused-but-set-variable]
   50 |  lli sm = 0;
      |      ^~
#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...