Submission #1010810

# Submission time Handle Problem Language Result Execution time Memory
1010810 2024-06-29T11:47:09 Z doducanh Sails (IOI07_sails) C++14
30 / 100
1000 ms 7176 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define h first
#define k second
const int maxn=1e5+7;
pair<int,int>a[maxn];
int dem[maxn];
int n;
main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i].h>>a[i].k;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        vector<pair<int,int>>v;
        for(int j=1;j<=a[i].h;j++){
            v.push_back({dem[j],j});
        }
        sort(v.begin(),v.end());
        for(int j=1;j<=a[i].k;j++){
            dem[v[j-1].k]++;
        }
    }
    int ans=0;
    for(int i=1;i<=100000;i++)ans+=dem[i]*(dem[i]-1)/2;
    cout<<ans;
    return 0;
}

Compilation message

sails.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 7 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 262 ms 604 KB Output is correct
2 Execution timed out 1033 ms 2800 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1028 ms 3624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 2612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 2132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 7176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 3360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 3820 KB Time limit exceeded
2 Halted 0 ms 0 KB -