Submission #553510

# Submission time Handle Problem Language Result Execution time Memory
553510 2022-04-26T04:53:18 Z MohamedFaresNebili Sails (IOI07_sails) C++14
0 / 100
1000 ms 6416 KB
#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")

        using namespace std;

        using ll = long long;
        using ii = pair<ll, ll>;
        using vi = vector<int>;

        #define ff first
        #define ss second
        #define pb push_back
        #define all(x) (x).begin(), (x).end()
        #define lb lower_bound
        #define int ll

        const int oo = 1e9 + 7;

        int N, arr[100001][2];

		int32_t main() {
            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            cin >> N;
            for(int l = 0; l < N; l++)
                cin >> arr[l][0] >> arr[l][1];
            int lo = 0, hi = 100001, res = oo * oo;
            while(lo <= hi) {
                int md = (lo + hi) / 2;
                bool ok = 1; int ans = 0;
                vector<int> st(100001, 0);
                for(int l = N - 1; l >= 0 && ok; l--) {
                    int curr = 0; vector<ii> vec;
                    for(int i = 0; i < arr[l][0]; i++)
                        vec.pb({st[i], i});
                    sort(all(vec));
                    for(int i = 0; i < arr[l][1]; i++) {
                        if(vec[i].ff > md) { ok = 0; break; }
                        ans += st[vec[i].ss]; st[vec[i].ss]++;
                    }
                }
                /// cout << ans << " " << md << "\n";
                if(ok) res = ans, hi = md - 1;
                else lo = md + 1;
            }
            cout << res << "\n";
		}

Compilation message

sails.cpp: In function 'int32_t main()':
sails.cpp:34:25: warning: unused variable 'curr' [-Wunused-variable]
   34 |                     int curr = 0; vector<ii> vec;
      |                         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 1240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 2548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 2552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 3820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 5988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 6104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 6416 KB Time limit exceeded
2 Halted 0 ms 0 KB -