제출 #62759

#제출 시각아이디문제언어결과실행 시간메모리
62759jjwdi0XCorr (KOI18_XCorr)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using pr = pair<int, int>;
using ll = long long;

int N, M, idx[300005];
ll sum[300005]
vector<pr> v;
ll ans;

int main() {
    scanf("%d", &N);
    for(int i=0, x, y; i<N; i++) {
        scanf("%d %d", &x, &y);
        sum[i+1] = 1LL * y;
        idx[i+1] = x;
    }
    scanf("%d", &M);
    for(int i=0, x, y; i<M; i++) {
        scanf("%d %d", &x, &y);
        v.push_back(pr(x, y));
    }
    int s, e;
    scanf("%d %d", &s, &e);
    for(int i=1; i<=N; i++) {
        sum[i] += sum[i-1];
    }

    for(auto it : v) {
        int idx1 = lower_bound(idx+1, idx+N+1, it.first + s) - idx,
            idx2 = upper_bound(idx+1, idx+N+1, it.first + e) - idx;
        ans += 1LL * (1LL * sum[idx2-1] - 1LL * sum[idx1-1]) * it.second;
    }
    printf("%lld\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

XCorr.cpp:8:1: error: expected initializer before 'vector'
 vector<pr> v;
 ^~~~~~
XCorr.cpp: In function 'int main()':
XCorr.cpp:15:9: error: 'sum' was not declared in this scope
         sum[i+1] = 1LL * y;
         ^~~
XCorr.cpp:21:9: error: 'v' was not declared in this scope
         v.push_back(pr(x, y));
         ^
XCorr.cpp:26:9: error: 'sum' was not declared in this scope
         sum[i] += sum[i-1];
         ^~~
XCorr.cpp:29:19: error: 'v' was not declared in this scope
     for(auto it : v) {
                   ^
XCorr.cpp:32:29: error: 'sum' was not declared in this scope
         ans += 1LL * (1LL * sum[idx2-1] - 1LL * sum[idx1-1]) * it.second;
                             ^~~
XCorr.cpp:32:33: error: 'idx2' was not declared in this scope
         ans += 1LL * (1LL * sum[idx2-1] - 1LL * sum[idx1-1]) * it.second;
                                 ^~~~
XCorr.cpp:32:33: note: suggested alternative: 'idx1'
         ans += 1LL * (1LL * sum[idx2-1] - 1LL * sum[idx1-1]) * it.second;
                                 ^~~~
                                 idx1
XCorr.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
XCorr.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
XCorr.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &M);
     ~~~~~^~~~~~~~~~
XCorr.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
XCorr.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &s, &e);
     ~~~~~^~~~~~~~~~~~~~~~~