Advertisement
deushiro

Untitled

Jun 25th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin >> n;
  6.     vector<int> a(22,0);
  7.     int ans = 0;
  8.     for(int i = 0; i < n; ++i){
  9.         int x;
  10.         cin >> x;
  11.         if(x > 20){
  12.             ans += i;
  13.             a[21]++;
  14.         }
  15.         else{
  16.             for(int j = 21 - x; j <= 21; ++j){
  17.                 ans += a[j];
  18.             }
  19.             a[x]++;
  20.         }
  21.     }
  22.     cout << ans << endl;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement