Submission #703063

# Submission time Handle Problem Language Result Execution time Memory
703063 2023-02-25T20:51:11 Z LucaLucaM Sails (IOI07_sails) C++17
30 / 100
1000 ms 3088 KB
#include <bits/stdc++.h>

using namespace std;

/**
luam fiecare sail in ordine crescatoare dupa inaltime:
luam cele mai putin frecvente k inaltimi
adunam la raspuns
**/

const int NMAX = 1e5;

struct sail
{
    int x, y;

    bool operator < (const sail aux) const
    {
        if (x == aux.x)
            return y > aux.y;
        return x < aux.x;
    }
};

sail a[NMAX + 5];

int f[NMAX + 5];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> a[i].x >> a[i].y;

    sort(a+1, a+n+1);

    long long ans = 0;

    for (int i=1; i<=n; i++)
    {
        vector<pair<int, int>>v;
        for (int j=1; j<=a[i].x; j++)
            v.push_back({f[j], j});
        sort(v.begin(), v.end());

        for (int j=0; j<a[i].y; j++)
            f[v[j].second]++;
    }

    for (int i=1; i<=NMAX; i++)
        ans += (long long) f[i] * (f[i] - 1) / 2;

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 9 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 286 ms 512 KB Output is correct
2 Execution timed out 1085 ms 1676 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 3088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 1200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1436 KB Time limit exceeded
2 Halted 0 ms 0 KB -