답안 #62758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62758 2018-07-30T02:09:43 Z jjwdi0 XCorr (KOI18_XCorr) C++11
0 / 100
5 ms 544 KB
#include <bits/stdc++.h>
using namespace std;
using pr = pair<int, int>;
using ll = long long;

int N, M, sum[300005], idx[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] = 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);
}

Compilation message

XCorr.cpp: In function 'int main()':
XCorr.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
XCorr.cpp:13: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:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &M);
     ~~~~~^~~~~~~~~~
XCorr.cpp:19: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:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &s, &e);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Incorrect 4 ms 544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Incorrect 4 ms 544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Incorrect 4 ms 544 KB Output isn't correct
3 Halted 0 ms 0 KB -