Submission #108040

# Submission time Handle Problem Language Result Execution time Memory
108040 2019-04-27T02:42:37 Z aer0park None (KOI18_XCorr) C++14
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll n,m,mx,mn,anw;
vector<pi> px,y;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		ll a,b;cin>>a>>b;
		if(i==0)
			px.push_back({a,b});
		else
			px.push_back({a,px[i-1].s+b});
	}	
	cin>>m;
	for(int i=0;i<m;i++)
	{
		ll a,b;cin>>a>>b;
		y.push_back({a,b});
	}	
	cin>>mn>>mx;
	for(int i=0;i<m;i++)
	{
		ll nw=y[i].f,nv=y[i].s,a=0,b=0;
		if(nw+mn>=0)
			a=lower_bound(px.begin(),px.end(),pi(nw+mn,0))-px.begin();
		if(nw+mx>=0)
		{
			b=lower_bound(px.begin(),px.end(),pi(nw+mx,0))-px.begin();
			if(b==0&&px[b].first>nw+mx)
				continue;
			if(px[b].first>nw+mx||b==px.size())
				b=b-1;
		}
		else
			continue;
		if(a==0)
			anw+=nv*px[b].second;
		if(a!=0)
			anw+=nv*(px[b].second-px[a-1].second);
	}
	cout<<anw;
	return 0;
}

Compilation message

XCorr.cpp: In function 'int main()':
XCorr.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(px[b].first>nw+mx||b==px.size())
                          ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -