제출 #46428

#제출 시각아이디문제언어결과실행 시간메모리
46428RezwanArefin01Election Campaign (JOI15_election_campaign)C++17
10 / 100
151 ms53084 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 1e5 + 10; vector<int> adj[maxn]; vector<ii> q[maxn]; ll dp[maxn]; int n, m; void solve23() { for(int i = 1; i <= n; i++) { dp[i] = dp[i - 1]; for(auto it : q[i]) { dp[i] = max(dp[i], dp[it.first - 1] + it.second); } } printf("%lld\n", dp[n]); exit(0); } int main(int argc, char const *argv[]) { #ifdef LOCAL_TESTING freopen("in", "r", stdin); #endif scanf("%d", &n); bool subtask23 = 1; for(int i = 1; i < n; i++) { int u, v; scanf("%d %d", &u, &v); subtask23 &= (u == i && v == u + 1); adj[u].push_back(v); adj[v].push_back(u); } scanf("%d", &m); for(int i = 0; i < m; i++) { int x, y, c; scanf("%d %d %d", &x, &y, &c); if(x > y) swap(x, y); q[y].emplace_back(x, c); } if(subtask23) solve23(); }

컴파일 시 표준 에러 (stderr) 메시지

election_campaign.cpp: In function 'int main(int, const char**)':
election_campaign.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
election_campaign.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
election_campaign.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
election_campaign.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &x, &y, &c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...