Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有点小水

Posted by 20010520 at 2021-10-20 19:40:58 on Problem 2393
#pragma warning(disable:4996)
#include <iostream>
#include <stdio.h>
using namespace std;
int N, S;
long long ans;
int ci[10005], yi[10005];
int main() {
	scanf("%d%d", &N, &S);
	for (int i = 0; i < N; i++)
		scanf("%d%d", ci + i, yi + i);
	int i = 0, j;
	while (true) {
		for ( j = i; j < N && (ci[i] + (j - i)*S <= ci[j]); j++)
			ans += (ci[i] + (j - i)*S)*yi[j];
		i = j;
		if (j == N) break;
	}
	cout << ans << endl;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator