More actions
({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;
}