Submission #1128461

#TimeUsernameProblemLanguageResultExecution timeMemory
1128461KasymKToll (BOI17_toll)C++20
46 / 100
3094 ms1868 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; }

Compilation message (stderr)

toll.cpp: In function 'int main()':
toll.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d%d%d%d", &k, &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d%d%d", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
toll.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
#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...