Submission #78701

# Submission time Handle Problem Language Result Execution time Memory
78701 2018-10-07T20:45:27 Z Vardanyan Sails (IOI07_sails) C++14
0 / 100
1000 ms 1908 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 100*1000+7;
pair<int,int> a[N];
int d[N];
int main(){
    int n;
    scanf("%d",&n);
    int H = 0;
    for(int i = 1;i<=n;i++){
        scanf("%d%d",&a[i].first,&a[i].second);
        H = max(H,a[i].first);
    }
    sort(a+1,a+1+n);
    long long ans = 0;
    int lst = 1;
    for(int i = 1;i<=n;i++){
        int x = (a[i].first-lst+1)-a[i].second;
        if(x>=0){
        for(int j = lst;j<=lst+a[i].second-1;j++) d[j]++;
        lst = lst+a[i].second;
        }
        if(x<0){
            for(int j = lst;j<=a[i].first;j++) d[j]++;
            x*=(-1);
            for(int j = 1;j<=x;j++) d[j]++;
            lst = x+1;
        }
    }
    for(int i = 1;i<=H;i++){
        long long u = d[i];
        u*=(u-1);
        u/=2;
        ans+=u;
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
sails.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a[i].first,&a[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 300 ms 964 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 407 ms 1188 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 1652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 1908 KB Time limit exceeded
2 Halted 0 ms 0 KB -