제출 #85083

#제출 시각아이디문제언어결과실행 시간메모리
85083tjdgus4384XCorr (KOI18_XCorr)C++14
0 / 100
3 ms376 KiB
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> num;
int xi[300001], yi[300001], sum[300001];

int main()
{
    int n, m, a, b, x, y;
    long long ans = 0;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d %d", &x, &y);
        num.push_back(x);
        if(i == 0) sum[i] = y;
        else sum[i] = sum[i - 1] + y;
    }
    scanf("%d", &m);
    for(int i = 0;i < m;i++)
    {
        scanf("%d %d", &xi[i], &yi[i]);
    }
    scanf("%d %d", &a, &b);
    for(int i = 0;i < m;i++)
    {
        int f = xi[i] + a;
        int s = xi[i] + b;
        int fx = lower_bound(num.begin(), num.end(), f) - num.begin();
        int sx = upper_bound(num.begin(), num.end(), s) - num.begin();
        if(num[sx] <= s) sx++;
        if(num[fx] < f) fx++;
        sx--;
        if(sx >= fx && fx >= 1) ans += (long long)yi[i] * (sum[sx] - sum[fx - 1]);
        else if(sx >= fx) ans += (long long) yi[i] * sum[sx];
    }
    printf("%lld", ans);
    return 0;
}

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

XCorr.cpp: In function 'int main()':
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:15: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:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
XCorr.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &xi[i], &yi[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
XCorr.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...