Submission #494371

# Submission time Handle Problem Language Result Execution time Memory
494371 2021-12-15T10:51:36 Z stefantaga Sails (IOI07_sails) C++14
25 / 100
1000 ms 2636 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
bool compare (pair <ll,ll> a,pair <ll,ll > b)
{
    return a.first<b.first||(a.first==b.first&&a.second>b.second);
}
ll n,i,h,k,j,maxi;
long long sum;
pair <ll,ll> sal[100005];
ll v[100005];
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>h>>k;
        maxi=max(maxi,h);
        for (j=1;j<=h;j++)
        {
            sal[j]={v[j],j};
        }
        sort (sal+1,sal+h+1,compare);
        for (j=1;j<=k;j++)
        {
            v[sal[j].second]++;
        }
    }
    for (j=1;j<=maxi;j++)
    {
        sum=sum+(1LL*v[j]*(v[j]-1)/2);
    }
    cout<<sum;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 451 ms 408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 1012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 972 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 1436 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 2560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 2636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 2528 KB Time limit exceeded
2 Halted 0 ms 0 KB -