답안 #309688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309688 2020-10-04T09:38:35 Z lukameladze Lottery (CEOI18_lot) C++14
100 / 100
982 ms 20856 KB
# include <bits/stdc++.h>
using namespace std;
long long n,l,k,a[300005],ans1[300005][105],cnt[300005],pr[300005],ans[300005][105],q,j,a1[300005],xx;
pair <int, int> b[300005];
int main()
{
     cin>>n>>l;
     for (int i=1; i<=n; i++)
     {
          cin>>a[i];
     }
     cin>>q;
     for (int i=1; i<=q; i++)
     {
     	cin>>b[i].first;
     	b[i].first=l-b[i].first;
     	b[i].second=i;
	}
	sort(b+1, b+q+1);
	j=1;
	for (int i=0; i<=l; i++)
	{
	     //if (i==0) cout<<j<<endl;
		while (b[j].first<=i && j<=q)
		{
			j++;
		}
		a1[i]=j-1; 
	}
//	cout<<a1[0]<<" "<<a1[1]<<" "<<a1[2]<<endl;
     for (int d=1; d<=n-1; d++)
     {
          for (int j=1; j<=n-d; j++)
          {
               if(a[j]==a[j+d]) cnt[j]++;
          }
          for (int j=1; j<=n-d; j++)
          {
               pr[j]=pr[j-1]+cnt[j];
               cnt[j]=0;
          }
          for (int j=l; j<=n-d; j++)
          {
               
               xx=pr[j]-pr[j-l];
        
    //   cout<<d<<" "<<j<<" "<<j-l<<" "<<xx<<" "<<a1[xx]<<endl;
      // cout<<j-l+1<<" "<<j-l+1+d<<" "<<a1[xx]<<endl;
               ans[j-l+1][a1[xx]]++; 
               ans[j-l+1+d][a1[xx]]++;
          }
     }
     // 0,1
  /*   for (int i=1; i<=q; i++)
     {
          for (int j=1; j<=n-l+1; j++)
          {
               cout<<ans[j][i]<<" ";
          }
          cout<<endl;
     }*/
     for (int i=q; i>=1; i--)
     {
          for (int j=1; j<=n-l+1; j++)
          {
               if(i==1)
               {
//      //              cout<<j<<" "<<b[i].second<<" "<<ans[j][b[i].second]<<" "<<ans[j][b[i+1].second]<<endl;
               }
               ans1[j][b[i].second]=ans1[j][b[i+1].second]+ans[j][i];
          }
     }
     for (int i=1; i<=q; i++)
     {
          for (int j=1; j<=n-l+1; j++)
          {
               cout<<ans1[j][i]<<" ";
          }
          cout<<endl;
     }
     cout<<endl;
 }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 2 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 2 ms 896 KB Output is correct
13 Correct 27 ms 3712 KB Output is correct
14 Correct 20 ms 2688 KB Output is correct
15 Correct 19 ms 2688 KB Output is correct
16 Correct 26 ms 3448 KB Output is correct
17 Correct 24 ms 3200 KB Output is correct
18 Correct 24 ms 3200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 840 ms 17044 KB Output is correct
2 Correct 850 ms 17016 KB Output is correct
3 Correct 649 ms 17144 KB Output is correct
4 Correct 596 ms 16764 KB Output is correct
5 Correct 296 ms 8824 KB Output is correct
6 Correct 550 ms 15864 KB Output is correct
7 Correct 299 ms 8824 KB Output is correct
8 Correct 386 ms 12280 KB Output is correct
9 Correct 574 ms 16524 KB Output is correct
10 Correct 596 ms 16760 KB Output is correct
11 Correct 38 ms 3704 KB Output is correct
12 Correct 376 ms 12024 KB Output is correct
13 Correct 345 ms 10360 KB Output is correct
14 Correct 355 ms 10488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 840 ms 17044 KB Output is correct
2 Correct 850 ms 17016 KB Output is correct
3 Correct 649 ms 17144 KB Output is correct
4 Correct 596 ms 16764 KB Output is correct
5 Correct 296 ms 8824 KB Output is correct
6 Correct 550 ms 15864 KB Output is correct
7 Correct 299 ms 8824 KB Output is correct
8 Correct 386 ms 12280 KB Output is correct
9 Correct 574 ms 16524 KB Output is correct
10 Correct 596 ms 16760 KB Output is correct
11 Correct 38 ms 3704 KB Output is correct
12 Correct 376 ms 12024 KB Output is correct
13 Correct 345 ms 10360 KB Output is correct
14 Correct 355 ms 10488 KB Output is correct
15 Correct 620 ms 16524 KB Output is correct
16 Correct 535 ms 15468 KB Output is correct
17 Correct 613 ms 17016 KB Output is correct
18 Correct 602 ms 16888 KB Output is correct
19 Correct 601 ms 16888 KB Output is correct
20 Correct 589 ms 16840 KB Output is correct
21 Correct 593 ms 16888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 640 KB Output is correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 2 ms 896 KB Output is correct
13 Correct 27 ms 3712 KB Output is correct
14 Correct 20 ms 2688 KB Output is correct
15 Correct 19 ms 2688 KB Output is correct
16 Correct 26 ms 3448 KB Output is correct
17 Correct 24 ms 3200 KB Output is correct
18 Correct 24 ms 3200 KB Output is correct
19 Correct 840 ms 17044 KB Output is correct
20 Correct 850 ms 17016 KB Output is correct
21 Correct 649 ms 17144 KB Output is correct
22 Correct 596 ms 16764 KB Output is correct
23 Correct 296 ms 8824 KB Output is correct
24 Correct 550 ms 15864 KB Output is correct
25 Correct 299 ms 8824 KB Output is correct
26 Correct 386 ms 12280 KB Output is correct
27 Correct 574 ms 16524 KB Output is correct
28 Correct 596 ms 16760 KB Output is correct
29 Correct 38 ms 3704 KB Output is correct
30 Correct 376 ms 12024 KB Output is correct
31 Correct 345 ms 10360 KB Output is correct
32 Correct 355 ms 10488 KB Output is correct
33 Correct 620 ms 16524 KB Output is correct
34 Correct 535 ms 15468 KB Output is correct
35 Correct 613 ms 17016 KB Output is correct
36 Correct 602 ms 16888 KB Output is correct
37 Correct 601 ms 16888 KB Output is correct
38 Correct 589 ms 16840 KB Output is correct
39 Correct 593 ms 16888 KB Output is correct
40 Correct 858 ms 17732 KB Output is correct
41 Correct 221 ms 2424 KB Output is correct
42 Correct 631 ms 17656 KB Output is correct
43 Correct 579 ms 16888 KB Output is correct
44 Correct 590 ms 16888 KB Output is correct
45 Correct 982 ms 20728 KB Output is correct
46 Correct 224 ms 2680 KB Output is correct
47 Correct 721 ms 20856 KB Output is correct
48 Correct 671 ms 18680 KB Output is correct
49 Correct 666 ms 19320 KB Output is correct