# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
209054 |
2020-03-13T03:33:53 Z |
srvlt |
Sails (IOI07_sails) |
C++14 |
|
1000 ms |
2148 KB |
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
void dout() { cerr << '\n'; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
cerr << " " << H;
dout(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
#define dbg(...) ;
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
const int N = 100003, H = 100000;
int n, a[N], ind[N], used[N];
vector <pii> vec;
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n;
int x, y;
for (int i = 1; i <= n; i++) {
cin >> x >> y;
vec.pb({x, y});
ind[i] = i;
}
sort(all(vec));
int h, k;
for (int i = 1; i <= n; i++) {
h = vec[i - 1].fi, k = vec[i - 1].se;
for (int j = 1; j <= h; j++) {
used[j] = 0;
}
while (k--) {
shuffle(ind + 1, ind + n + 1, rng);
int mn = -1;
for (int j = 1; j <= n; j++) {
if (ind[j] > h || used[ind[j]]) {
continue;
}
if (mn == -1 || a[ind[j]] < a[mn]) {
mn = ind[j];
}
}
a[mn]++;
used[mn] = 1;
}
}
ll ans = 0;
for (int i = 1; i <= H; i++) {
int x = a[i];
ans += (ll)x * (x - 1) / 2;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
376 KB |
Output is correct |
2 |
Execution timed out |
1090 ms |
376 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
888 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
1144 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
2148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
1776 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
1776 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |