Submission #78699

# Submission time Handle Problem Language Result Execution time Memory
78699 2018-10-07T20:05:31 Z Vardanyan Sails (IOI07_sails) C++14
30 / 100
1000 ms 6032 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);
    for(int i = 1;i<=n;i++){
        scanf("%d%d",&a[i].first,&a[i].second);
    }
    sort(a+1,a+1+n);
    for(int i = 1;i<=n;i++){
        vector<pair<int,int> > ind;
        for(int j = 1;j<=a[i].first;j++) ind.push_back({d[j],j});
        sort(ind.begin(),ind.end());
        for(int j = 0;j<a[i].second;j++) d[ind[j].second]++;
    }
    long long ans = 0;
    for(int i = 1;i<=N-2;i++){
        long long c = d[i];
        c*=(c-1);
        c/=2;
        ans+=c;
    }
    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:10: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 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 432 KB Output is correct
2 Correct 2 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 484 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 13 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 340 ms 948 KB Output is correct
2 Execution timed out 1074 ms 2188 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 2188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 2188 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 2336 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 5452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 5452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 6032 KB Time limit exceeded
2 Halted 0 ms 0 KB -