답안 #771632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771632 2023-07-03T07:34:57 Z PAndaS Fountain (eJOI20_fountain) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

long find_next(vector<long> d, long i){
    long orig = d[i];
    for(int j = i + 1; j < d.size(); j++) if(d[j] > orig) return j;
    return -1;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long n, q;
    cin >> n >> q;
    vector<long> d(n);
    vector<int> c(n);
    for(long i = 0; i < n; i++) cin >> d[i] >> c[i];
    vector<vector<pair<long, long>>> paths(n, vector<pair<long, long>>());
    long tmp;
    for(long i = 0; i < n; i++){
        tmp = i;
        while(tmp != -1){
            paths[i].push_back(pair<long, long>(c[tmp], tmp));
            tmp = find_next(d, tmp);
        }
        paths[i].push_back(pair<long, long>(LONG_MAX, -1));
    }
    for(long i = 0; i < n; i++){
        for(long j = 1; j < paths[i].size() - 1; j++){
            paths[i][j].first += paths[i][j - 1].first;
        }
    }
    long res, v;
    long l, r, m;
    for(long i = 0; i < q; i++){
        cin >> res >> v;
        res--;
        l = 0;
        r = paths[res].size() - 1;
        while(l < r){
            m = (l + r) / 2;
            for(long j = l; j <= r; j++) lo << paths[res][j].first << ' ';
            if(paths[res][m].first >= v) r = m;
            else l = m + 1;
        }
        cout << paths[res][r].second + 1 << '\n';
    }
    return 0;
}

Compilation message

fountain.cpp: In function 'long int find_next(std::vector<long int>, long int)':
fountain.cpp:7:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int j = i + 1; j < d.size(); j++) if(d[j] > orig) return j;
      |                        ~~^~~~~~~~~~
fountain.cpp: In function 'int main()':
fountain.cpp:31:27: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(long j = 1; j < paths[i].size() - 1; j++){
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
fountain.cpp:44:42: error: 'lo' was not declared in this scope; did you mean 'l'?
   44 |             for(long j = l; j <= r; j++) lo << paths[res][j].first << ' ';
      |                                          ^~
      |                                          l