답안 #494494

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494494 2021-12-15T15:01:12 Z ammar2000 Mountains (NOI20_mountains) C++17
79 / 100
2000 ms 8992 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int MOD=1e9+7;
ll n,a[SI],masr[SI],an[SI],ans;
map <ll,ll> mp;
int main()
{
   cin>>n;
   bool fl=0;
   for (int i=0;i<n;i++)
    {cin>>a[i];
    if (i&&a[i]<a[i-1])
        fl=1;}
    if (fl==0)
    {
        cout << 0;
        return 0;
    }
    if (n>10010)
    {for (int i=0;i<n;i++)
    {
        for (int t=0;t<a[i];t++)
            an[i]+=mp[t];
        mp[a[i]]++;
    }
    mp.clear();
    for (int i=n-1;i>=0;i--)
    {
        for (int t=0;t<a[i];t++)
            masr[i]+=mp[t];
        mp[a[i]]++;
    }
    for (int i=0;i<n;i++)
        ans+=masr[i]*an[i];
    cout <<ans ;}
    else
    {
        for (int i=1;i<n-1;i++)
   {
       ll f,s;
       f=s=0;
       for (int r=0;r<i;r++)
        f+=(a[i]>a[r]);
       for(int r=i+1;r<n;r++)
        s+=(a[i]>a[r]);
        ans+=f*s;
   }
   cout <<ans;
    }
   return 0;
}

Compilation message

Mountains.cpp: In function 'int main()':
Mountains.cpp:53:8: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |        for(int r=i+1;r<n;r++)
      |        ^~~
Mountains.cpp:55:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |         ans+=f*s;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 185 ms 2548 KB Output is correct
3 Correct 194 ms 2628 KB Output is correct
4 Correct 195 ms 2568 KB Output is correct
5 Correct 189 ms 2536 KB Output is correct
6 Correct 190 ms 2612 KB Output is correct
7 Correct 188 ms 2620 KB Output is correct
8 Correct 191 ms 2648 KB Output is correct
9 Correct 194 ms 2540 KB Output is correct
10 Correct 203 ms 2544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 7236 KB Output is correct
2 Correct 59 ms 7272 KB Output is correct
3 Correct 55 ms 7316 KB Output is correct
4 Correct 68 ms 7312 KB Output is correct
5 Correct 50 ms 7264 KB Output is correct
6 Correct 47 ms 7236 KB Output is correct
7 Correct 47 ms 7236 KB Output is correct
8 Correct 43 ms 2572 KB Output is correct
9 Correct 41 ms 2500 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 7236 KB Output is correct
2 Correct 59 ms 7272 KB Output is correct
3 Correct 55 ms 7316 KB Output is correct
4 Correct 68 ms 7312 KB Output is correct
5 Correct 50 ms 7264 KB Output is correct
6 Correct 47 ms 7236 KB Output is correct
7 Correct 47 ms 7236 KB Output is correct
8 Correct 43 ms 2572 KB Output is correct
9 Correct 41 ms 2500 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 428 ms 7304 KB Output is correct
12 Correct 427 ms 7288 KB Output is correct
13 Correct 414 ms 7356 KB Output is correct
14 Correct 425 ms 7320 KB Output is correct
15 Correct 461 ms 7240 KB Output is correct
16 Correct 415 ms 7352 KB Output is correct
17 Correct 439 ms 7364 KB Output is correct
18 Correct 45 ms 2608 KB Output is correct
19 Correct 50 ms 2512 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 95 ms 364 KB Output is correct
12 Correct 83 ms 328 KB Output is correct
13 Correct 75 ms 356 KB Output is correct
14 Correct 80 ms 356 KB Output is correct
15 Correct 86 ms 356 KB Output is correct
16 Correct 90 ms 332 KB Output is correct
17 Correct 81 ms 332 KB Output is correct
18 Correct 87 ms 360 KB Output is correct
19 Correct 75 ms 360 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 7236 KB Output is correct
2 Correct 59 ms 7272 KB Output is correct
3 Correct 55 ms 7316 KB Output is correct
4 Correct 68 ms 7312 KB Output is correct
5 Correct 50 ms 7264 KB Output is correct
6 Correct 47 ms 7236 KB Output is correct
7 Correct 47 ms 7236 KB Output is correct
8 Correct 43 ms 2572 KB Output is correct
9 Correct 41 ms 2500 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 428 ms 7304 KB Output is correct
12 Correct 427 ms 7288 KB Output is correct
13 Correct 414 ms 7356 KB Output is correct
14 Correct 425 ms 7320 KB Output is correct
15 Correct 461 ms 7240 KB Output is correct
16 Correct 415 ms 7352 KB Output is correct
17 Correct 439 ms 7364 KB Output is correct
18 Correct 45 ms 2608 KB Output is correct
19 Correct 50 ms 2512 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Execution timed out 2087 ms 8992 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 185 ms 2548 KB Output is correct
3 Correct 194 ms 2628 KB Output is correct
4 Correct 195 ms 2568 KB Output is correct
5 Correct 189 ms 2536 KB Output is correct
6 Correct 190 ms 2612 KB Output is correct
7 Correct 188 ms 2620 KB Output is correct
8 Correct 191 ms 2648 KB Output is correct
9 Correct 194 ms 2540 KB Output is correct
10 Correct 203 ms 2544 KB Output is correct
11 Correct 54 ms 7236 KB Output is correct
12 Correct 59 ms 7272 KB Output is correct
13 Correct 55 ms 7316 KB Output is correct
14 Correct 68 ms 7312 KB Output is correct
15 Correct 50 ms 7264 KB Output is correct
16 Correct 47 ms 7236 KB Output is correct
17 Correct 47 ms 7236 KB Output is correct
18 Correct 43 ms 2572 KB Output is correct
19 Correct 41 ms 2500 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 428 ms 7304 KB Output is correct
22 Correct 427 ms 7288 KB Output is correct
23 Correct 414 ms 7356 KB Output is correct
24 Correct 425 ms 7320 KB Output is correct
25 Correct 461 ms 7240 KB Output is correct
26 Correct 415 ms 7352 KB Output is correct
27 Correct 439 ms 7364 KB Output is correct
28 Correct 45 ms 2608 KB Output is correct
29 Correct 50 ms 2512 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 2 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 2 ms 204 KB Output is correct
38 Correct 2 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 95 ms 364 KB Output is correct
42 Correct 83 ms 328 KB Output is correct
43 Correct 75 ms 356 KB Output is correct
44 Correct 80 ms 356 KB Output is correct
45 Correct 86 ms 356 KB Output is correct
46 Correct 90 ms 332 KB Output is correct
47 Correct 81 ms 332 KB Output is correct
48 Correct 87 ms 360 KB Output is correct
49 Correct 75 ms 360 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Execution timed out 2087 ms 8992 KB Time limit exceeded
52 Halted 0 ms 0 KB -