# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1128461 | KasymK | Toll (BOI17_toll) | C++20 | 3094 ms | 1868 KiB |
// I want to go high as fuck tonight...
// Music name => (Gyzyl Ysyk)
// Authors: A$OK, SazYelme, Swizzy347 and Ma.Gallery
// Hash your favorite words.
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 5e4+5;
const int K = 5;
const ll INF = 1e18;
const int INF1 = 1e9;
int mal[N][K];
ll dp[N];
int main(){
// freopen("file.txt", "r", stdin);
int k, n, m, q;
scanf("%d%d%d%d", &k, &n, &m, &q);
memset(mal, 63, sizeof mal);
while(m--){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
mal[a][b%k]=c;
}
while(q--){
int a, b;
scanf("%d%d", &a, &b);
dp[a]=0;
for(int i = a+1; i <= b; ++i)
dp[i]=INF;
for(int i = a; i < (b/k)*k; ++i)
for(int j = 0; j < k; ++j)
umin(dp[(i/k)*k+k+j], dp[i]+mal[i][j]);
if(dp[b]>=INF1)
puts("-1");
else
printf("%lld\n", dp[b]);
}
return 0;
}
컴파일 시 표준 에러 (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... |