-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathgrade.cpp
36 lines (35 loc) · 770 Bytes
/
grade.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# include <cstdio>
# include <algorithm>
using namespace std;
int cmp (int x, int y)
{
if (x<=y) return 0;
else return 1;
}
int i,n,pornire;
int a[5005],start[5005],stop[5005];
int main ()
{
freopen ("grade.in", "r", stdin);
freopen ("grade.out", "w", stdout);
scanf ("%d", &n);
for (i=1; i<=n; ++i)
scanf ("%d", &a[i]);
sort (a+1,a+n+1, cmp);
for (i=1; i<=n+1; ++i)
{
if (!start[a[i]]) start[a[i]]=i;
if (a[i]<a[i-1]) stop[a[i-1]]=i-1;
}
for (i=1; i<=n && a[i]!=0; ++i)
{
if (start[a[i]]!=stop[a[i]]) pornire=i+1;
else pornire=stop[a[i]];
while (a[i])
{
--a[pornire];
printf ("%d %d\n", i, pornire);
}
}
return 0;
}