Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

1R/2016 07 05

From ZeroWiki
Revision as of 07:35, 5 July 2016 by 165.194.27.163 (talk)

오늘의 문제

경진대회

참가자

이름 학번
박인서 15학번

코드

박인서

#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	setbuf(stdout, NULL);
	
	int TC;
	int test_case;
    
	scanf("%d", &TC);
	for(test_case = 1; test_case <= TC; test_case++) {
	    int n;
	    vector<int> a;
	    scanf("%d", &n);
	    for(int i=0;i<n;i++){
	        int t;
	        scanf("%d", &t);
	        a.push_back(t);
	    }
	    sort(a.begin(),a.end());
	    
	    int max=0;
	    for(int i=0;i<n;i++)
	        if(max<a[i]+n-i) max=a[i]+n-i;
	    
	    int cnt=0;
	    for(int i=0;i<n;i++)
	        if(max<=a[i]+n) cnt++;

	    printf("Case #%d\n%d\n", test_case, cnt);
	}
	return 0;
}

아이디어

박인서