zoukankan      html  css  js  c++  java
  • 1060 爱丁顿数 (25分)

    6 7 6 9 3 10 8 2 7 8
    2 3 6 6 7 7 8 8 9 10

    a=10    1天超过1公里
    a=9     2天超过2公里
    a=8     3天超过3公里
    a=8     4天超过4公里
    a=7     5天超过5公里
    a=7     6天超过6公里
    a=6     结束...   n-i-1
    
    #include<iostream>
    #include<algorithm>
    #include<cmath>
    
    using namespace std;
    const int INF = 100001;
    int main() {
    	int n, i, j;
    	cin >> n;
    
    	int* a = new int[n];
    	for (i = 0; i < n; i++) {
    		cin >> a[i];
    	}
    	sort(a, a + n);
    
    	if (a[0] > n) {
    		cout << n << endl;
    	}
    	else {
    		for (i = n - 1; i >= 0; i--) {
    			if (a[i] <= n - i) {
    				cout << n - i - 1 << endl;
    				break;
    			}
    		}
    	}
    	return 0;
    }
    
  • 相关阅读:
    OpenCV鼠标事件
    相对复杂一些的爬虫,针对拒绝爬虫的网站
    CSS
    JS
    JS
    JS
    JS
    TypeScript
    微信小程序
    微信小程序
  • 原文地址:https://www.cnblogs.com/tanghm/p/12663529.html
Copyright © 2011-2022 走看看