zoukankan      html  css  js  c++  java
  • 智力大冲浪

    题目描述

    思路

    代码

    #include <cstdio>
    
    int n, m;
    bool rec[505];
    struct Node {
    	int a, b;
    } arr[505], tmp;
    inline int read() {
    	int s = 0, f = 1;
    	char ch = getchar();
    	while (ch < '0' || ch > '9') {
    		if (ch == '-') f = -1;
    		ch = getchar();
    	}
    	while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    	return s * f;
    }
    void qsort(int L, int R) {
    	int l = L, r = R;
    	int mid = arr[l + r >> 1].b;
    	while (l < r) {
    		while (arr[l].b > mid) l++;
    		while (arr[r].b < mid) r--;
    		if (l <= r) {
    			tmp = arr[l];
    			arr[l] = arr[r];
    			arr[r] = tmp;
    			l++, r--;
    		}
    	}
    	if (l < R) qsort(l, R);
    	if (L < r) qsort(L, r);
    }
    int main() {
    	n = read(), m = read();
    	for (int i = 1; i <= m; ++i) arr[i].a = read();
    	for (int i = 1; i <= m; ++i) arr[i].b = read();
    	qsort(1, m);
    	for (int i = 1; i <= m; ++i) {
    		bool flag = false;
    		for (int j = arr[i].a; j >= 1; --j) {
    			if (!rec[j]) {
    				rec[j] = true; 
    				flag = true;
    				break;
    			}
    		}
    		if (!flag) n -= arr[i].b;
    	}
    	printf("%d
    ", n);
    	return 0;
    }
    
  • 相关阅读:
    day 16
    day 15
    day 14
    day 13
    Unity Shader UnityCG.cginc
    Unity Shader 包含内置文件
    Unity Shader 如何使用属性
    Unity Shader 顶点/片元着色器的基本结构
    Unity Shader 的基础结构
    git文件名大小敏感
  • 原文地址:https://www.cnblogs.com/liuzz-20180701/p/11558001.html
Copyright © 2011-2022 走看看