Submission #564951

#TimeUsernameProblemLanguageResultExecution timeMemory
564951CookiePilot (NOI19_pilot)C++14
78 / 100
234 ms3364 KiB
#include <bits/stdc++.h> using namespace std; #define LIFESUCKS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define ld long double #define ar array #include<cstdio> #define vt vector #include<fstream> ifstream fin("closing.in"); ofstream fout("closing.out"); #include<fstream> #define pb push_back #define all(c) (c).begin(), (c).end() #define fi first #define se second #define vt vector using namespace std; int main() { int n, q; cin >> n >> q; ll a[n]; for(int i = 0; i < n; i++)cin >> a[i]; if(n <= 1000 || q == 1){ for(int i = 0; i < q; i++){ ll x; cin >> x; ll res = 0; ll cr = 0; for(int j = 0; j < n; j++){ if(a[j] <= x)cr++; else{ res += (cr * (cr + 1)) / 2; cr = 0; } } res += (cr * (cr + 1)) / 2; cout << res << "\n"; } }else{ for(int i =0; i < q; i++){ int x; cin >> x; ll id = upper_bound(a, a + n, x) - a; ll res = id * (id + 1) / 2; cout << res << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...