Submission #1124433

#TimeUsernameProblemLanguageResultExecution timeMemory
1124433_8_8_Security Guard (JOI23_guard)C++20
25 / 100
85 ms12764 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = (int)2e5 + 12, b = 18; const ll inf = (ll)1e10; int n, m, q, s[N]; vector<int> g[N]; void test() { cin >> n >> m >> q; vector<int> vals; for(int i = 1; i <= n; i++) { cin >> s[i]; vals.push_back(s[i]); } for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } sort(vals.begin(), vals.end()); ll res = 0; ll sub = 0; for(int i = 0; i < n; ) { int j = i; int c = 0; while(j < n && vals[j] == vals[i]) { c++; j++; } res += m * 1ll * (vals[i] - sub); sub += (vals[i] - sub); m -= c; if(vals[i] == s[1]) m++; if(vals[i] == s[n]) m++; i = j; } cout << res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--) test(); }
#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...