Submission #885408

#TimeUsernameProblemLanguageResultExecution timeMemory
885408AlphaMale06Sails (IOI07_sails)C++14
25 / 100
1054 ms6884 KiB
#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)

sails.cpp: In function 'int main()':
sails.cpp:31:13: warning: unused variable 'f' [-Wunused-variable]
   31 |         int f=p.F; int s=p.S;
      |             ^
sails.cpp:31:24: warning: unused variable 's' [-Wunused-variable]
   31 |         int f=p.F; int s=p.S;
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...