Submission #349599

#TimeUsernameProblemLanguageResultExecution timeMemory
349599Elephant52Wiring (IOI17_wiring)C++11
0 / 100
1 ms384 KiB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define INF 1000000000
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)

int64_t min_total_length(vi r, vi b) {
    int N = r.size(), M = b.size();
    
    int64_t res = 0;
    
    for (int cur_height : r) {
        int64_t score = 0;
        auto it = lower_bound(b.begin(), b.end(), cur_height);
        
        if (it != b.end())
            score = max(score, (int64_t)*it);
        
        if (it != b.begin())
            --it;
        
        score = max(score, (int64_t)*it);
        
        res += score;
    }
    
    return res;
}

Compilation message (stderr)

wiring.cpp: In function 'int64_t min_total_length(vi, vi)':
wiring.cpp:18:9: warning: unused variable 'N' [-Wunused-variable]
   18 |     int N = r.size(), M = b.size();
      |         ^
wiring.cpp:18:23: warning: unused variable 'M' [-Wunused-variable]
   18 |     int N = r.size(), M = b.size();
      |                       ^
#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...