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

1R/2016 07 05: Difference between revisions

From ZeroWiki
({CREATE})
 
No edit summary
Line 8: Line 8:
| 이름
| 이름
| 학번
| 학번
|-
| 박인서
| 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;
}


= 아이디어 =
= 아이디어 =
== 박인서 ==



Revision as of 07:35, 5 July 2016

오늘의 문제

경진대회

참가자

이름 학번
박인서 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;
}

아이디어

박인서