Submission #73795

# Submission time Handle Problem Language Result Execution time Memory
73795 2018-08-29T04:11:56 Z 아인따(#2278) Schools (IZhO13_school) C++11
0 / 100
435 ms 8588 KB
#include<cstdio>
#include<algorithm>
#define BS 100000
using namespace std;
int n, A[301000], B[301000], X, Y, c;
long long sum;
struct point {
	int a, ck;
	bool operator < (const point &p)const {
		return a != p.a ? a < p.a : ck < p.ck;
	}
}w[301000];
bool Pos(int d) {
	int i;
	for (i = 1; i <= n; i++) {
		if (A[i] <= B[i] + d) {
			w[i] = { B[i]+d,1 };
		}
		else w[i] = { A[i],0 };
	}
	sort(w + 1, w + n + 1);
	sum = 0, c = 0;
	for (i = n; i > n - X - Y; i--) {
		sum += w[i].a;
		if (w[i].ck)c++;
	}
	return c >= Y;
}
int main() {
	int b = 0, e = 2*BS, mid, r = 0, i;
	scanf("%d%d%d", &n,&X,&Y);
	for (i = 1; i <= n; i++)scanf("%d%d", &A[i], &B[i]);
	while (b <= e) {
		mid = (b + e) >> 1;
		if (Pos(mid - BS)) {
			r = mid - BS;
			e = mid - 1;
		}
		else b = mid + 1;
	}
	Pos(r);
	printf("%lld\n",sum - Y*r);
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n,&X,&Y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
school.cpp:32:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 1; i <= n; i++)scanf("%d%d", &A[i], &B[i]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 3 ms 568 KB Output is correct
7 Correct 14 ms 584 KB Output is correct
8 Correct 11 ms 620 KB Output is correct
9 Correct 11 ms 684 KB Output is correct
10 Correct 12 ms 796 KB Output is correct
11 Correct 11 ms 800 KB Output is correct
12 Correct 11 ms 936 KB Output is correct
13 Correct 82 ms 1744 KB Output is correct
14 Correct 183 ms 3296 KB Output is correct
15 Correct 409 ms 6312 KB Output is correct
16 Incorrect 435 ms 8588 KB Output isn't correct
17 Halted 0 ms 0 KB -