Submission #1010947

# Submission time Handle Problem Language Result Execution time Memory
1010947 2024-06-29T14:53:41 Z doducanh Sails (IOI07_sails) C++14
40 / 100
1000 ms 3584 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++){
        int k=a[i].k;
        int h=a[i].h;
        int pos=h-k;
        int l=pos,r=pos;
        while(l>1&&dem[l-1]==dem[pos])l--;
        while(r<h&&dem[r+1]==dem[pos])r++;
        for(int j=r+1;j<=h;j++)dem[j]++;
        for(int j=l;j<=l+(k-(h-r)-1);j++)dem[j]++;
    }
    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 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 15 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 852 KB Output is correct
2 Correct 49 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 183 ms 1284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 479 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 3152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 3248 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 3584 KB Time limit exceeded
2 Halted 0 ms 0 KB -