Submission #1010888

# Submission time Handle Problem Language Result Execution time Memory
1010888 2024-06-29T13:33:24 Z doducanh Sails (IOI07_sails) C++14
40 / 100
1000 ms 5808 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);
    priority_queue<int>q;
    int w=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=a[i].h-w;j++){
            q.push(0);
        }
        vector<int>v;
        while(a[i].k--){
            v.push_back(q.top()-1);
            q.pop();
        }
        for(int x:v)q.push(x);
        w=a[i].h;
    }
    int res=0;
    while(q.size()){
        int tmp=q.top();
        res+=(-tmp)*(-tmp-1)/2;
        q.pop();
    }
    cout<<res;
    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 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 4 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 148 ms 2396 KB Output is correct
2 Correct 142 ms 3596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 3000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 2896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 3412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 5808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 3668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1101 ms 4076 KB Time limit exceeded
2 Halted 0 ms 0 KB -