# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885408 | AlphaMale06 | Sails (IOI07_sails) | C++14 | 1054 ms | 6884 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
const int N = 100001;
int cnt[N];
signed main()
{
int n;
cin >> n;
vector<pair<int, int>> vc;
for(int i=0; i< n; i++){
int x, y;
cin >> x >> y;
if(x==y)cnt[x]++;
else{
vc.pb({x, y});
}
}
for(int i=N-2; i>0; i--){
cnt[i]+=cnt[i+1];
}
sort(vc.begin(), vc.end());
for(pair<int, int> p : vc){
int f=p.F; int s=p.S;
vector<pair<int, int>> upd;
for(int i=1; i<=p.F; i++){
upd.pb({cnt[i], i});
}
sort(upd.begin(), upd.end());
for(int i=0; i<p.S; i++){
cnt[upd[i].S]++;
}
}
int ans=0;
for(int i=1; i<10; i++){
ans+=cnt[i]*(cnt[i]-1);
}
cout << ans/2 << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |