제출 #1083135

#제출 시각아이디문제언어결과실행 시간메모리
1083135I_am_Polish_GirlElection (BOI18_election)C++14
0 / 100
2 ms344 KiB
#pragma target("arch=icelake-server") #include <iostream> #include <vector> #include <algorithm> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <stack> #include <queue> #include <cmath> #include <random> #include <chrono> #include <iomanip> #include <bitset> using namespace std; #define int long long typedef long long ll; typedef long double ld; int log_ = 11; int inf = 4000000007000000007; long long mod = 1000000007; int p = 499; int NADIYA = 39; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector <int> a(n); for (int i = 0; i < n; i++) { char c; cin >> c; if (c == 'C') a[i] = 1; else a[i] = -1; } vector <int> pref1(n); int p = 0; for (int i = 0; i < n; i++) { p += a[i]; pref1[i] = p; } p = 0; vector <int> pref2(n); for (int i = n - 1; i >= 0; i--) { p += a[i]; pref2[i] = p; } p = 0; int q; cin >> q; for (int j = 0; j < q; j++) { int l, r; cin >> l >> r; l--; r--; int x = 0; if (l != 0) x = pref1[l - 1]; int mn = pref1[l] - x; for (int i = l; i <= r; i++) { mn = min(mn, pref1[i] - x); } int y = 0; if (r+1 != n) y = pref2[r + 1]; int mn2 = pref2[r] - y; for (int i = l; i <= r; i++) { mn2 = min(mn2, pref2[i] - y); } cout << max(max(-mn, -mn2), 0ll) << "\n"; } } /*5 1 2 1 2 3 1 2 4 1 1 5 4 */

컴파일 시 표준 에러 (stderr) 메시지

election.cpp:1: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    1 | #pragma target("arch=icelake-server")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...