이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define INF 1e18
#define fi first
#define se second
#define FOR(i, k, n) for(ll i = k; i <= n; i++)
#define FOR1(i, k, n) for(ll i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "BESIEGE.inp"
#define output "BESIEGE.out"
#define rf freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int base = 998244353;
void add(int &a, int b)
{
a += b;
if(a >= mod) a -= mod;
if(a < 0) a += mod;
}
pii a[maxn];
bool vis[maxn];
int main()
{
fastio;
int n, k;
cin >> n >> k;
FOR(i, 1, n)
cin >> a[i].fi >> a[i].se;
if(n == 1)
{
cout << 0;
re;
}
ll ans = 0;
sort(a + 1, a + 1 + n);
FOR(i, 2, n)
if(a[i].fi == a[1].fi)
ans += k, a[i].fi++;
int cnt = 0;
while(cnt < n - 1)
{
int id;
FOR(i, 2, n)
if(!vis[i])
{
id = i;
break;
}
vis[id] = 1;
cnt++;
ans += a[1].se;
int truoc = a[id].fi;
FOR(i, id + 1, n)
{
if(!vis[i] && a[i].fi > truoc)
{
truoc = a[i].fi;
vis[i] = 1;
cnt++;
}
}
}
cout << ans - a[1].se;
re;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:59:11: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
59 | vis[id] = 1;
| ~~~~~~~~^~~
# | 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... |