Submission #467277

#TimeUsernameProblemLanguageResultExecution timeMemory
467277mansurFountain (eJOI20_fountain)C++17
60 / 100
1578 ms3196 KiB
#include<bits/stdc++.h> #pragma optimize ("g",on) #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ll long long #define pb push_back #define nl '\n' #define popb pop_back() #define sz size() #define ld long double #define ull unsigned long long #define ff first #define ss second #define fix fixed << setprecision #define pii pair<int, int> #define E exit (0) #define int long long const int inf = (1ll << 62ll), N = 1e6 + 2, mod = 1e9 + 7; vector<pii> dd = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; signed main() { //freopen("invtrans.in", "r", stdin); //freopen("invtrans.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); int n, q; cin >> n >> q; int d[n + 1], c[n + 1]; bool ok = 1; for (int i = 1; i <= n; i++) { cin >> d[i] >> c[i]; if (i > 1 && d[i] <= d[i - 1]) ok = 0; } if (ok) { int pref[n + 1]; pref[0] = 0; for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] + c[i]; while (q--) { int r, v; cin >> r >> v; int tl = r, tr = n, ans =0; while (tl <= tr) { int mid = (tl + tr) / 2; if (pref[mid] - pref[r - 1] >= v) { ans = mid; tr = mid - 1; }else tl = mid + 1; } cout << ans << nl; } return 0; } while (q--) { int r, v; cin >> r >> v; int last = 0, ans = 0; for (int i = r; i <= n; i++) { if (d[i] > last) { last = d[i]; v -= c[i]; if (v <= 0) { ans = i; break; } } } cout << ans << nl; } }

Compilation message (stderr)

fountain.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...