Submission #85086

# Submission time Handle Problem Language Result Execution time Memory
85086 2018-11-18T12:30:44 Z tjdgus4384 None (KOI18_XCorr) C++14
0 / 100
3 ms 416 KB
#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] - b;
        int s = xi[i] - a;
        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;
}

Compilation message

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 time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 416 KB Output isn't correct
3 Halted 0 ms 0 KB -