Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int n;
- cin >> n;
- vector<int> a(22,0);
- int ans = 0;
- for(int i = 0; i < n; ++i){
- int x;
- cin >> x;
- if(x > 20){
- ans += i;
- a[21]++;
- }
- else{
- for(int j = 21 - x; j <= 21; ++j){
- ans += a[j];
- }
- a[x]++;
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement