| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1339116 | po_rag526 | Sails (IOI07_sails) | C++20 | 1093 ms | 131072 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pii pair<ll,ll>
#define F first
#define S second
#define LOO(i,a,b) for (ll i = a; i<=b; i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define OOL(i,a,b) for (ll i = b; i >=a; i--)
vector<pii> cool;
ll ttl[1'000'01];
ll offset = 0;
ll answer = 0;
ll best = 1e18;
void dod(int x, int left, int last) {
if (x==sz(cool)-1) {
best=min(best,answer);
// cout << answer << endl;
return;
}
LOO(j,last,cool[x].F-1) {
ttl[j]++;
answer+=ttl[j]*(ttl[j]-1)/2 - (ttl[j]-1)*(ttl[j]-2)/2;
if (left==1) {
dod(x+1,cool[x+1].S,0);
}
else {
dod(x,left-1,j+1);
}
answer-=ttl[j]*(ttl[j]-1)/2 - (ttl[j]-1)*(ttl[j]-2)/2;
ttl[j]--;
}
}
void solve() {
LOO(i,0,1e5) ttl[i]=0;
int n;
cin>>n;
cool = vector<pii>(n);
LOO(i,0,n-1)cin>>cool[i].F>>cool[i].S;
cool.push_back({-1,-1});
dod(0,cool[0].S,0);
cout << best << '\n';
}
signed main() {
iostream::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
while (t--) solve();
}| # | 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... | ||||
